[CentralOH] sqlite3

m g miles.groman at gmail.com
Fri Feb 19 19:54:11 CET 2010


Sorry, I am not sure I follow exactly...

Are you getting the primary key from the other system?  And do you
need to preserve that key?   Why not autoincrement that ?

http://www.sqlite.org/faq.html#q1


On Fri, Feb 19, 2010 at 9:21 AM, Mark Erbaugh <mark at microenh.com> wrote:
> I'm having a performance issue with sqlite3.  I have a Python program that reads in an file output from another system over which I have no control, parses the records in that file and inserts the data as rows into a sqlite table.  The table has an INTEGER PRIMARY KEY field.  The input files have150k to 300k records.  When the records in input file are already in order by the primary key, the inserts are at least an order of magnitude faster. For example 10 seconds versus 200.
>
> If I remove the PRIMARY KEY constraint, the insert speed improves. However, there can be duplicate keys in the input data which need to be dealt with (either ignored or replace the previous row).
>
> The brute force solution would be to read the data into a list and sort the list before inserting it into sqlite, but I wonder if there is a sqlite setting I'm missing.
>
> Thanks,
> Mark
>
>
>
> _______________________________________________
> CentralOH mailing list
> CentralOH at python.org
> http://mail.python.org/mailman/listinfo/centraloh
>


More information about the CentralOH mailing list