cancel
Showing results for 
Search instead for 
Did you mean: 

Why is Python sqlanydb so slow when fetching resultsets with SAP IQ and WAN ?

Former Member
3,770

I noticed that when you use python sqlanydb module on a WAN (when the server is in a different datacenter), the sqlanydb module is very slow : it can take 16-30 seconds to fetch 1000 rows. Looks like the prefetching does not work. dbisql works fine with the same query and connection.

From a WAN :

$ time ./test.py real 0m20.118s user 0m0.112s sys 0m0.043s

From the same LAN :

real 0m0.168s user 0m0.081s sys 0m0.050s

Test case test.py:

import sqlanydb

def connect(): print "Before connecting"

conn = sqlanydb.connect(DSN="IQ_DB",UID="foo",PWD="bar", preFetchRows="1000")
print "After connecting"
return conn

c = connect()

cursor = c.cursor() query = """ select top 1000 foo from dbo.bar"""

cursor.execute(query) print "Executed"

results = cursor.fetchall() print "Fetched all"

for r in results: print r[0]

Will raise this to the github project as well. We are SAP customers btw.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member

The problem comes from this IQ server option : prefetch

http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc00801.1604/doc/html/san12...

You need to set it to default 'Always'. The value 'Conditional' caused the issue.