On 13 Feb 2017, at 9:03pm, jose isaias cabrera <jic...@barrioinvi.net> wrote:

>> Can you set an index on id, projId, and Xtrab ?
> Already have one for each.
> 
> CREATE INDEX OpPid ON LSOpenProjects (ProjID);
> CREATE INDEX XtraBLSOpenProjects ON LSOpenProjects (XtraB);

No.  This does not do the same thing as one index which combines all three 
columns.

Imaging you had a phone book with firstname, surname, phonenumber.
I ask you to look up "Paul Smith".

You have one index with firstname and another index with surname.
You can pick either index but they will not take you to the right entry.
One index can take you straight to "Paul", but then you have to search all the 
"Paul" entries looking for "Smith".  There could be thousands of "Paul" entries.
The other index would take you straight to "Smith" but then you’d have to 
search through them for "Paul".  There might be thousands of "Smiths".

But create an index on (firstname,surname) and then you can go straight to the 
first "Paul Smith", then immediately to all the other people with the same name.

You do not make good indexes by indexing columns individually.  You make good 
indexes by looking at a WHERE clause and making an index which is perfect for 
that clause.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to