On 21 Mar 2011, at 5:46pm, Enrico Thierbach wrote:

> On 21.03.2011, at 06:34, Simon Slavin wrote:
> 
>> Suppose you have a TABLE employees with ten thousand rows and no indexes, 
>> and you execute
>> 
>> SELECT id,firstname,surname FROM employees WHERE firstname='Guilherme' AND 
>> age=46
>> 
>> The query optimizer has a choice.  It can first pick out all the Guilhermes, 
>> and then find those who are the right age, or it can first pick out all the 
>> 46 year olds, then find any with the right firstname. [snip]
> 
> Is it really that way? I somehow assumed in that non-index case there is just 
> a single table scan involved? Fetching each record, calculating 
> firstname='Guilherme' AND age=46 for each, and selecting the matching 
> records? 

Well Richard corrected me that the results of ANALYZE actually comes into play 
when two INDEXes do exist, and I am no longer certain about what I wrote above. 
 It would probably become apparent if we looked at the results of an EXPLAIN 
QUERY PLAN for that situation.

Sorry about the wrong steer, everyone.

Simon.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to