On Dec 17, 2011, at 2:59 PM, rivka wrote: > Hi, > > I am building a database on my macbook air computer using python 2.7 > and sqlalchemy 0.73.The database has main items which are linked > through relationship to multiple other tables with relevant data for > the item. I am in the process of data entry - and adding data to each > of the tables takes about 0.000176 of a sec - so - for all the simple > fields it takes about 0.015471sec per item. The biggest problem is > adding a list of citations for each item - since the citations are > self referential - hence I need to append them to both the citing and > cited items. > Adding each citation takes on the average 0.1615 of a sec ! that is > 1000x LONGER than each of the other item fields! While adding a > citation involves calling up another item from the database - still - > this looks excruciatingly slow and is an absolute show stopper for me > (data entry will take months!). So - I need to find out what I am > doing wrong (and I am sure that this is the case). > > ============= > The access to the item: p1 = q_pat.get(n) takes around 0.3-0.5 of a > second - and that is an absolute killer. Why is it so slow and how do > I accelerate it?
First off, congratulations for deciding to enter the world of Python profiling - it's something we all have to do, quite often. I'll point you to a SO post I wrote which pretty comprehensively covers both Python-agnostic as well as SQLAlchemy specific techniques: http://stackoverflow.com/questions/1171166/how-can-i-profile-a-sqlalchemy-powered-application/1175677#1175677 I haven't looked closely at your example but if your profiling leads to areas within SQLAlchemy's mechanisms that need explanation, feel free to check back here for specifics! -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.