Re: [sqlite] Optimize a query

2007-04-17 Thread bartsmissaert
Interesting and thanks for that tip. Is there a performance penalty from structuring the query like that? I take it that there will be. RBS > Martin Pelletier <[EMAIL PROTECTED]> wrote: >> This is news to me. Why can't SQlite use more than one index? >> > > It can. You just have to tell it to

Re: [sqlite] Optimize a query

2007-04-17 Thread drh
Martin Pelletier <[EMAIL PROTECTED]> wrote: > This is news to me. Why can't SQlite use more than one index? > It can. You just have to tell it to explicitly by restructuring your SQL. As an example, consider this query: SELECT * FROM table1 WHERE a=5 AND b=11; Suppose there are two

Re: [sqlite] Optimize a query

2007-04-17 Thread Paul Smith
At 16:46 17/04/2007, you wrote: This is news to me. Why can't SQlite use more than one index? Possibly because it's 'SQ *Lite*'? The query optimiser in SQLite is a lot less powerful than in some other SQL databases - but then it's a fraction of the size as well... Instead of having two

Re: [sqlite] Optimize a query

2007-04-17 Thread Martin Pelletier
This is news to me. Why can't SQlite use more than one index? Samuel R. Neff wrote: afaik SQLite will only use one index per table -- Martin Pelletier Informatique / Software Development Infodev Electronic Designers International Inc. Tel : +1 (418) 681-3539, poste /ext. 114 Fax : +1 (418)

RE: [sqlite] Optimize a query

2007-04-17 Thread Samuel R. Neff
afaik SQLite will only use one index per table so if you have a where clause "WHERE public = 1 and _rowid IN (...)" it will use an index on public and not _rowid. Swapping the where clause around should have a significant impact: select _rowid, public_id, vote_count,

[sqlite] Optimize a query

2007-04-17 Thread Marco Bambini
This query on a small database sometimes takes more than 40 seconds: select _rowid, public_id, vote_count, status, summary, component, date (date_modified), quickfix from reports where public = 1 AND _rowid IN (select distinct r._rowid from reports r, segments s where s.report_id = r._rowid

Re: [sqlite] Optimize a query

2007-04-17 Thread Martin Jenkins
Marco Bambini wrote: This query on a small database sometimes takes more than 40 seconds: select _rowid, public_id, vote_count, status, summary, component, date(date_modified), quickfix from reports where public = 1 AND _rowid IN (select distinct r._rowid from reports r, segments s where