> Index columns can only be used from left to right, with no skips,
> to satisfy the conditions of the query.

Ah, yes, I forgot about that one. So, I will need some more indexes.

RBS


-----Original Message-----
From: Igor Tandetnik [mailto:[EMAIL PROTECTED] 
Sent: 04 August 2007 15:49
To: SQLite
Subject: [sqlite] Re: Re: How does SQLite choose the index?

RB Smissaert <[EMAIL PROTECTED]>
wrote:
> So, basically it is best to make one large index (apart from the
> primary
> integer key?) that includes all fields that could be in a WHERE
> clause or a
> JOIN or a GROUP BY or a HAVING or an ORDER BY?

That depends on the queries you want to speed up. Index columns can only 
be used from left to right, with no skips, to satisfy the conditions of 
the query. For example, if you have an index on columns (a, b, c) and a 
query like

select * from t where a='x' and c='z';

then the index can be used to satisfy a='x' condition, but then a linear 
check of all records having a='x' is performed to satisfy c='z'. If you 
run such a query often and need it to run fast, you may want another 
index on (a, c), or perhaps (a, c, b).

Igor Tandetnik 


----------------------------------------------------------------------------
-
To unsubscribe, send email to [EMAIL PROTECTED]
----------------------------------------------------------------------------
-




-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to