Re: [sqlite] INSERT OR IGNORE vs INSERT WHERE NOT EXISTS

2012-04-08 Thread Petite Abeille
On Apr 8, 2012, at 12:25 AM, Josh Gibbs wrote: > SQLite: INSERT OR IGNORE INTO test_table VALUES('prop','val'); > Postgres: INSERT INTO test_table SELECT 'prop','val' WHERE NOT EXISTS (SELECT > 1 FROM test_table WHERE property='prop'); My 2¢… The first variant, insert or ignore, is arguably mo

Re: [sqlite] INSERT OR IGNORE vs INSERT WHERE NOT EXISTS

2012-04-07 Thread Josh Gibbs
Thanks, but I can't do that because I'm batching up multiple writes in transactions to get performance. The errors cause the whole transaction to need to be rolled back. On 8/04/2012 11:20 a.m., Igor Tandetnik wrote: Josh Gibbs wrote: The method that must be used is as follows: CREATE TABL

Re: [sqlite] INSERT OR IGNORE vs INSERT WHERE NOT EXISTS

2012-04-07 Thread Igor Tandetnik
Josh Gibbs wrote: > The method that must be used is as follows: > > CREATE TABLE test_table (property TEXT PRIMARY KEY, value TEXT); > > SQLite: INSERT OR IGNORE INTO test_table VALUES('prop','val'); > Postgres: INSERT INTO test_table SELECT 'prop','val' WHERE NOT EXISTS > (SELECT 1 FROM test_ta

[sqlite] INSERT OR IGNORE vs INSERT WHERE NOT EXISTS

2012-04-07 Thread Josh Gibbs
Looking for some performance advice before I go testing this myself. I'm porting some code that's currently running with SQLite as its DB engine over to postgres. SQLite will still be an option so I need to maintain compatibility across both engines. I've run into the common postgres problem