Closed GoogleCodeExporter closed 9 years ago
Original comment by abhigyan...@in.ibm.com
on 22 Oct 2008 at 5:31
[deleted comment]
Same here. Fetching rows is very slow. Example code:
import time
import ibm_db_dbi
# (here should be config code)
db = ibm_db_dbi.connect(cfg.dbhost, cfg.dbuser, cfg.dbpass)
c = db.cursor()
sel = "SELECT name FROM product;" # about 9500 rows
# test 1: using fetchone()
tm_o = time.time()
tm_n = time.time()
print 'start test 1: %s' % (tm_n - tm_o)
c.execute(sel)
tm_o = tm_n
tm_n = time.time()
print 'execute: %s' % (tm_n - tm_o)
while 1:
ret = c.fetchone()
if ret == None: break
tm_o = tm_n
tm_n = time.time()
print 'fetch by one: %s' % (tm_n - tm_o)
# test 1: using fetchall()
tm_o = time.time()
tm_n = time.time()
print 'start test 2: %s' % (tm_n - tm_o)
c.execute(sel)
tm_o = tm_n
tm_n = time.time()
print 'execute: %s' % (tm_n - tm_o)
ret = c.fetchall()
tm_o = tm_n
tm_n = time.time()
print 'fetch all: %s' % (tm_n - tm_o)
returns:
start test 1: 0.0
execute: 0.530999898911
fetch by one: 224.213000059
start test 2: 0.0
execute: 0.578000068665
fetch all: 194.164999962
Im using IBM db2 v8 on redhat. Python is running on local machine, winXP sp3
32bit,
python 2.6, ibm_db v 1.0, IBM DB2 client v9
Original comment by mynth...@gmail.com
on 26 Nov 2009 at 11:54
ibm_db_dbi.py
_fetch_helper() line 1195
this is what caouses fetch to work slow:
row = ibm_db.fetch_tuple(self.stmt_handler)
unfortunatelly i have no C skills to see if it can be faster.
Original comment by mynth...@gmail.com
on 26 Nov 2009 at 1:33
I have made some changes in dbi wrapper to increase performance. This will also
decreases the latency time.
The modified dbi wrapper is in attachment of
http://groups.google.com/group/ibm_db/browse_thread/thread/2f6bdffa68524ce1
discussion thread.
Please download dbi wrapper and replace the existing ibm_db_dbi.py with this
one(at
location “../site-packages/ibm_db.py2.x-xxx.egg/”).
Give it a try and let me know hows it works.
Original comment by rahul.pr...@in.ibm.com
on 8 Apr 2010 at 6:51
Fixed in ibm_db-1.0.2
Original comment by rahul.pr...@in.ibm.com
on 30 Apr 2010 at 6:02
Original issue reported on code.google.com by
wavefor...@gmail.com
on 15 Oct 2008 at 12:01Attachments: