470,618 Members | 1,723 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,618 developers. It's quick & easy.

slow sql server DB reads

I run a python website on a IIS server. I replaced my flat file DB
with SQL server, but the reads are very slow. 7 seconds for 3 querrys
like these

conn= adodbapi.connect( "Provider=SQLOLEDB.1;Persist Security
Info=False;User ID=sa;Password=xxx;Initial Catalog=dlpl;Data
Source=(local)" )
crsr = conn.cursor()
sql = "select SessionKey, SessionValue from ASPSessionState
where GUID='%s'" % self.id
crsr.execute(sql)
while 1:
info = crsr.fetchone()
if not info:
break
strKey = str(info[0])

Opening the database is already good for 2 seconds.
Anyone know how to speed it up?
Jul 19 '05 #1
2 1403
On 23 May 2005 14:15:03 -0700, sm**@scarlet.be (bart) declaimed the
following in comp.lang.python:

sql = "select SessionKey, SessionValue from ASPSessionState
where GUID='%s'" % self.id
crsr.execute(sql)
Recommendation is to use something of the nature

sql = "select .... where GUID=%s"
crsr.execute(sql, self.id)

.execute() should properly quote the argument.
while 1:
info = crsr.fetchone()
Probably not a speed improvement but...

for info in crsr.fetchall(): #or something like that, check the
# api spec strKey = str(info[0])
I presume you make use of SessionValue somewhere in the program
<G>

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 19 '05 #2
If GUID is not a key in the database make it one. That
way you won't have to do serial reads through the entire
table to locate matching entries.

It is hard to be more specific because we don't know how
many records are in ASPSessionState table. If there are
only a few, the problem is probably elsewhere. If there
are many, indexing on GUID would provide speed improvement.

Larry Bates

bart wrote:
I run a python website on a IIS server. I replaced my flat file DB
with SQL server, but the reads are very slow. 7 seconds for 3 querrys
like these

conn= adodbapi.connect( "Provider=SQLOLEDB.1;Persist Security
Info=False;User ID=sa;Password=xxx;Initial Catalog=dlpl;Data
Source=(local)" )
crsr = conn.cursor()
sql = "select SessionKey, SessionValue from ASPSessionState
where GUID='%s'" % self.id
crsr.execute(sql)
while 1:
info = crsr.fetchone()
if not info:
break
strKey = str(info[0])

Opening the database is already good for 2 seconds.
Anyone know how to speed it up?

Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Buddy Ackerman | last post: by
46 posts views Thread by dunleav1 | last post: by
5 posts views Thread by Lennart | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.