On Thu, Jun 17, 2010 at 09:07:56AM -0500, Black, Michael (IS) scratched on the 
wall:
> I sense the beginning of a "How to use indexes" page.
>  
> Things you need know:
>     Only one index is used per query (or insert??).

  It isn't that bad.

  In general, it is "one index PER TABLE, per query."  But it isn't
  even that bad.  Sub-queries can often use their own set of indexes,
  or any other situation when it is cheaper to extract a bunch of small
  data sets and combine then, rather than perform an scan, can use
  multiple indexes associated to the same table.  
  
  The easiest case to understand is a chain of OR'ed WHERE conditions...
  if we assume each OR will produce a moderate to small sub-set, it can
  be cheaper to use an index to generate each sub-set and then OR the 
  sub-sets, rather than do a full table scan and apply the OR chain to
  each row.

  Yeah, it gets complex real fast....

   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it,
 but showing it to the wrong people has the tendency to make them
 feel uncomfortable." -- Angela Johnson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to