Home > Archive > Sybase Database > December 2005 > Cursor Vs Join/Select









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Cursor Vs Join/Select
deepak.rathore@gmail.com

2005-12-02, 9:23 am

I think usually joins r faster than cursors

But is there any scenario, where it is preferable to use cursors ....?

Plz suggest

Carl Kayser

2005-12-02, 11:23 am

<deepak.rathore@gmail.com> wrote in message
news:1133535872.271698.125440@g47g2000cwa.googlegroups.com...
>I think usually joins r faster than cursors
>
> But is there any scenario, where it is preferable to use cursors ....?
>
> Plz suggest
>


The exception that I have for using cursors is:

SP_1 provides info on an object, e.g., table, index, whatever. If I want
the info for all tables, indexes, whatever then I usually (but not always)
prefer to use a cursor in SP_2 that executes SP_1 <individual object> for
the fetched objects.

I prefer the modularization of not maintaining (essentially) two copies of
code.


Larry Coon

2005-12-02, 8:23 pm

Carl Kayser wrote:

> The exception that I have for using cursors is:
>
> SP_1 provides info on an object, e.g., table, index, whatever. If I want
> the info for all tables, indexes, whatever then I usually (but not always)
> prefer to use a cursor in SP_2 that executes SP_1 <individual object> for
> the fetched objects.


The other use I've had for cursors is when I need to compile
info from the SYS___ tables in all databases.


Larry Coon
University of California
--CELKO--

2005-12-03, 9:23 am

I have written five cursors in my career. I know I could have avoided
three of them if we had the CASE expression in those days. The only
use I found was for getting the first "good enough" solution in an
NP-complete problem like The Traveling Saleman.
A pure SQL slution tends to get all the solutions and thus we have a
Cartesian explosion.

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com