On Feb 13, 2009, at 4:07 AM, koranthala wrote:
>
> Hi,
> I am working on a Python application which does approximately 1000
> updates at a time every 3 seconds in a Sqlite File Database using
> SqlAlchemy. On timing it in a 2GHz machine, I found that it is taking
> ~1.01 seconds to do the same.
> Is it possible to increase the speed of the same? My application
> is quite a complex one, and taking 1 second for the updates is slowing
> the overall performance considerably.
> I checked Sqlite page - and they mention that 25000 text UPDATEs
> with an index (which is what I am doing) takes 2.4 seconds (this is
> Sqlite2 data - sqlite3 should be faster). I guess should mean that
> 1000 text UPDATEs should take 0.1 seconds.
>
> The inserts I do is as follows:
> BEGIN:
> 2009-02-13 14:34:40,703 INFO sqlalchemy.engine.base.Engine.0x..10
> UPDATE data SET status=? WHERE data."index" = ?
> 2009-02-13 14:34:40,703 INFO sqlalchemy.engine.base.Engine.0x..10
> ['True', 68762]
>
> ...
> (1000)
> ...
>
> COMMIT
to INSERT many rows very quickly, use the "executemany" style of
insertion:
connection.execute(table.insert(), [{'foo':'row1'}, {'foo':'row2'},
{'foo':'row3'}, ...])
this will allow the DBAPI to optimize the execution of INSERT
statements using native speed. You will only have average
performance using the ORM to insert rows so if you need speed I would
advise against its usage for this operation.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---