[Tutor] Weird speed issue with mysql vs php

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Fri Aug 20 09:05:37 CEST 2004



On Thu, 19 Aug 2004, orbitz wrote:

> Hello I have a situation where I'm rewriting a bunch of legacy PHP code
> in python. This issue I'm having is my python program takes about 4.5
> hours to write and the PHP equivalent takes about 15 minutes.

Hello!

Ok, that's very odd.  I think we need to see the code, both the PHP and
the Python code if possible.  The performance difference shouldn't be that
striking.  But since it is, let's see if we can find why.

One thing that might be happening is the following: MySQLdb's default
cursor type is a client-site cursor.  People have in the past found that
switching to a server side cursor type makes their database programs much
faster.  It looks something like:

###
import MySQLdb.cursors
import MySQLdb
conn = MySQLdb.connect(db=mydatabase,
                       cursorclass=MySQLdb.cursors.SSCursor)
###


But from what you mentioned earlier:

> The longest query is limited to 20 results all the time.

the result set here is so small that I can't believe that the cursor type
would contribute so much.  So I think we'll need to look at the code
closely.  Can you post if up, or link it from a web site if it's large?


Good luck to you!



More information about the Tutor mailing list