Sorry guys. Added some error checking and discovered a bug in the mysql index creation - I've fixed it and imports don't degrade anything like they used to now. I've just imported 15K hands at 20+/second when it used to be down at 5/sec after 10K hands or so.

This commit is contained in:
sqlcoder 2009-08-03 01:30:51 +01:00
parent 1a63c62cf1
commit 745baf139f

View File

@ -733,8 +733,8 @@ class Database:
if self.backend == self.MYSQL_INNODB: if self.backend == self.MYSQL_INNODB:
print "creating mysql index ", idx['tab'], idx['col'] print "creating mysql index ", idx['tab'], idx['col']
try: try:
c.execute( "alter table %s add index %s(%s)" s = "alter table %s add index %s(%s)" % (idx['tab'],idx['col'],idx['col'])
, (idx['tab'],idx['col'],idx['col']) ) c.execute(s)
except: except:
print " create fk failed: " + str(sys.exc_info()) print " create fk failed: " + str(sys.exc_info())
elif self.backend == self.PGSQL: elif self.backend == self.PGSQL:
@ -742,9 +742,8 @@ class Database:
# mod to use tab_col for index name? # mod to use tab_col for index name?
print "creating pg index ", idx['tab'], idx['col'] print "creating pg index ", idx['tab'], idx['col']
try: try:
print "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col']) s = "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col'])
c.execute( "create index %s_%s_idx on %s(%s)" c.execute(s)
% (idx['tab'], idx['col'], idx['tab'], idx['col']) )
except: except:
print " create index failed: " + str(sys.exc_info()) print " create index failed: " + str(sys.exc_info())
else: else:
@ -859,20 +858,18 @@ class Database:
if self.backend == self.MYSQL_INNODB: if self.backend == self.MYSQL_INNODB:
print "creating mysql index ", idx['tab'], idx['col'] print "creating mysql index ", idx['tab'], idx['col']
try: try:
self.get_cursor().execute( "alter table %s add index %s(%s)" s = "create index %s on %s(%s)" % (idx['col'],idx['tab'],idx['col'])
, (idx['tab'],idx['col'],idx['col']) ) self.get_cursor().execute(s)
except: except:
pass print " create idx failed: " + str(sys.exc_info())
elif self.backend == self.PGSQL: elif self.backend == self.PGSQL:
# mod to use tab_col for index name? # mod to use tab_col for index name?
print "creating pg index ", idx['tab'], idx['col'] print "creating pg index ", idx['tab'], idx['col']
try: try:
print "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col']) s = "create index %s_%s_idx on %s(%s)" % (idx['tab'], idx['col'], idx['tab'], idx['col'])
self.get_cursor().execute( "create index %s_%s_idx on %s(%s)" self.get_cursor().execute(s)
% (idx['tab'], idx['col'], idx['tab'], idx['col']) )
except: except:
print " ERROR! :-(" print " create idx failed: " + str(sys.exc_info())
pass
else: else:
print "Only MySQL and Postgres supported so far" print "Only MySQL and Postgres supported so far"
return -1 return -1