[SOLVED] I'm confused about MySQLdb server side cursor and client cursor


I’m using python-mysql(MySQLdb) to query Mysql server.
There are two cursor modules: one is client cursor, such as:

cursor = db.cursor(MySQLdb.cursors.DictCursor)

Another one is server side cursor,such as:

cursor = db.cursor(MySQLdb.cursors.SSDictCursor)

The doc says Server side cursor means that Mysql would cache some results in mysql server side and then send them out to the client. I’m so confused about this, let’s say, if I wanna kill one mysql server I could just use multiple server side cursors and then mysql will be dead because of memory ran out. Furthermore, does server size cursor make any sense? By default Mysql mechanism is that when mysql retrieved one record it would send it out the client immediately. Does make any sense to cache the results and then send them out?

I really don’t known which cursor I should use, client cursor or server side cursor?


I’m not the greatest Database Ninja around, but often times things get built into server software that aren’t really useful in the general or common cases, but are really, really awesome in that one little corner case.

Nimdil gave you one, but this is another:


This person asserts that SScursor is more of an “unbuffered” cursor.

This sort of seems to contradict that:


Anyway, it sort of seems that the use for Server Side Cursors are when you’re dealing with datasets such that your query could overwhelm the client.

Answered By – Petro

Answer Checked By – David Marino (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *