When will a FAST_FORWARD cursor have a work table (and is this something to avoid)?

Just a hunch, but normally a TOP-ORDER BY requires SQL Server to buffer the result in some way (either the index scan’s result or indeed the entire result in a temp structure, or anything in between). One could argue that for cursors this is also necessary even when ordering by the primary key (as in … Read more

How to find Current open Cursors in Oracle

Total cursors open, by session: select a.value, s.username, s.sid, s.serial# from v$sesstat a, v$statname b, v$session s where a.statistic# = b.statistic# and s.sid=a.sid and b.name=”opened cursors current”; Source: http://www.orafaq.com/node/758 As far as I know queries on v$ views are based on pseudo-tables (“x$” tables) that point directly to the relevant portions of the SGA, so … Read more

How to efficiently use MySQLDB SScursor?

I am in agreement with Otto Allmendinger’s answer, but to make explicit Denis Otkidach’s comment, here is how you can iterate over the results without using Otto’s fetch() function: import MySQLdb.cursors connection=MySQLdb.connect( host=”thehost”,user=”theuser”, passwd=”thepassword”,db=”thedb”, cursorclass = MySQLdb.cursors.SSCursor) cursor=connection.cursor() cursor.execute(query) for row in cursor: print(row)

Why are relational set-based queries better than cursors?

The main reason that I’m aware of is that set-based operations can be optimised by the engine by running them across multiple threads. For example, think of a quicksort – you can separate the list you’re sorting into multiple “chunks” and sort each separately in their own thread. SQL engines can do similar things with … Read more

tech