[sqlite] Optimising a query with several criteria

2011-03-13 Thread Ian Hardingham
Hey guys. I've optimised most of my queries to work effectively, but I have one which is sometimes causing me problems. It is: SELECT * FROM multiturnTable WHERE rowid in (SELECT rowid FROM multiturnTable WHERE player1 ='?' UNION ALL SELECT rowid FROM multiturnTable WHERE player2 = '?') AND

Re: [sqlite] Optimising a query with several criteria

2011-03-13 Thread Black, Michael (IS)
You don't say how big your database is. My guess is when you see the server using a lot of RAM (and exactly how are you measuring this?) that it's flushing its disk cache. If you're on Unix use vmstat to see what your OS cache is doing. So...perhaps if you increase SQLite's internal cache it

Re: [sqlite] sqlite-users Digest, Vol 39, Issue 13

2011-03-13 Thread Garry Watkins
Not sure why you are using a subselect with a union all. Try this: SELECT * FROM multiturnTable WHERE (player1 ='?' OR player2 ='?') AND (complete=0 OR p1SubmitScore=0 OR p2SubmitScore=0) AND p1Declined=0 AND p2Declined=0 Message: 1 Date: Sun, 13 Mar 2011 11:43:30 +

Re: [sqlite] Optimising a query with several criteria

2011-03-13 Thread Ian Hardingham
Hi Michael, thanks for this. My database is 40 megabytes (and growing slowly) - is that a reasonable cachesize? On 13/03/2011 13:07, Black, Michael (IS) wrote: You don't say how big your database is. My guess is when you see the server using a lot of RAM (and exactly how are you measuring

Re: [sqlite] Optimising a query with several criteria

2011-03-13 Thread Simon Slavin
On 13 Mar 2011, at 11:43am, Ian Hardingham wrote: SELECT * FROM multiturnTable WHERE rowid in (SELECT rowid FROM multiturnTable WHERE player1 ='?' UNION ALL SELECT rowid FROM multiturnTable WHERE player2 = '?') AND (complete=0 OR p1SubmitScore=0 OR p2SubmitScore=0) AND p1Declined=0 AND

Re: [sqlite] sqlite-users Digest, Vol 39, Issue 13

2011-03-13 Thread Igor Tandetnik
Garry Watkins ga...@dynafocus.com wrote: Not sure why you are using a subselect with a union all. SELECT * FROM multiturnTable WHERE (player1 ='?' OR player2 ='?') Because OR prevents SQLite from using an index on either player1 or player2, and turns the query into full table scan. --

Re: [sqlite] Optimising a query with several criteria

2011-03-13 Thread Black, Michael (IS)
To paraphase Forrect Gump, reasonable is as reasonable does. It's computed by cachesize*pagesize Pagesize is limited to 65536 but I don't know what cachesize is lmited to (docs don't say). You can make it abosolutely huge if you have the memory for it. And 40MB sounds awfully small to me.

[sqlite] strange UB detected

2011-03-13 Thread Eugene N
Hi I detected a strange feature of sqlite3. Somebody called it Pointer Liberation army strike. uchar* pblah[1]; pblah[0] = (uchar*)malloc(10); pblah[1] = (uchar*)malloc(10); // notice the order sqlite3* db; // this call magically kills pblah[1] by making it 0x0 int ret =

Re: [sqlite] strange UB detected

2011-03-13 Thread Drake Wilson
Quoth Eugene N neverov.biks.0...@gmail.com, on 2011-03-13 18:14:49 +0200: uchar* pblah[1]; pblah[0] = (uchar*)malloc(10); pblah[1] = (uchar*)malloc(10); // notice the order sqlite3* db; Your C code is broken. pblah is an array of 1 element, which is accessible (among other ways) as

Re: [sqlite] strange UB detected

2011-03-13 Thread Eugene N
Thanks! I forgot about C array numeration... Sorry for being an arse. Eugene 2011/3/13 Drake Wilson dr...@begriffli.ch Quoth Eugene N neverov.biks.0...@gmail.com, on 2011-03-13 18:14:49 +0200: uchar* pblah[1]; pblah[0] = (uchar*)malloc(10); pblah[1] = (uchar*)malloc(10); //

Re: [sqlite] strange UB detected

2011-03-13 Thread Jay A. Kreibich
On Sun, Mar 13, 2011 at 06:14:49PM +0200, Eugene N scratched on the wall: uchar* pblah[1]; pblah[0] = (uchar*)malloc(10); pblah[1] = (uchar*)malloc(10); // notice the order Any ideas why? Because pblah is a *one*-element array. -j -- Jay A. Kreibich J A Y @ K R E I B I.C H

Re: [sqlite] [sqlite-dev] Amalgamation code doesn't supoort limit on update / delete

2011-03-13 Thread Pavel Ivanov
http://lmgtfy.com/?q=SQLITE_ENABLE_UPDATE_DELETE_LIMIT+site%3Asqlite.orgl=1 If you look for description of SQLITE_ENABLE_UPDATE_DELETE_LIMIT on the resulting page you'll see that it's not a bug or oversight, it's a documented feature. Pavel On Sun, Mar 13, 2011 at 2:46 PM, Steven Hartland

Re: [sqlite] [sqlite-dev] Amalgamation code doesn't supoort limit on update / delete

2011-03-13 Thread Robert Hairgrove
On Sun, 2011-03-13 at 14:53 -0400, Pavel Ivanov wrote: On Sun, Mar 13, 2011 at 2:46 PM, Steven Hartland steven.hartl...@multiplay.co.uk wrote: After spending many hours banging my head trying to figure out why sqlite-jdbc was erroring on a delete with a limit even when compiled with

Re: [sqlite] sqlite-users Digest, Vol 39, Issue 13

2011-03-13 Thread Nico Williams
On Sun, Mar 13, 2011 at 10:31 AM, Igor Tandetnik itandet...@mvps.org wrote: Garry Watkins ga...@dynafocus.com wrote: Not sure why you are using a subselect with a union all. SELECT *  FROM multiturnTable WHERE (player1 ='?' OR player2 ='?') Because OR prevents SQLite from using an index on