Database query optimization

Posted by hdx on Stack Overflow See other posts from Stack Overflow or by hdx
Published on 2010-06-03T17:45:02Z Indexed on 2010/06/03 17:54 UTC
Read the original article Hit count: 321

Ok my Giant friends once again I seek a little space in your shoulders :P

Here is the issue, I have a python script that is fixing some database issues but it is taking way too long, the main update statement is this:

cursor.execute("UPDATE jiveuser SET username = '%s' WHERE userid = %d" % (newName,userId))

That is getting called about 9500 times with different newName and userid pairs...

Any suggestions on how to speed up the process? Maybe somehow a way where I can do all updates with just one query?

Any help will be much appreciated!

PS: Postgres is the db being used.

© Stack Overflow or respective owner

Related posts about python

Related posts about database