On 30 Jun 2010, at 12:05am, J. Rios wrote:

> Sorry for posting on top of the message,

No problem.  Adding new text at the bottom of a post, and trimming what you 
quote just enough that people understand your new text, make your own message 
clear and encourage people to reply to it.  Look at what I did: there's no 
point in quoting your .sig so I didn't.  There's no point in quoting the post 
you're replying to so I didn't.  I chopped both those pieces out.

>  This is my original post with the query you request
> 
> I have the next table
> 
> table1( id INTEGER, name VARCHAR, id2 INTEGER, name2 VARCHAR, year INTEGER
> );
> 
> I have created the next indexes : index1( name ), index2( id2 ), index3(
> name2 );
> 
> The database have about 200,000 records.
> The next query takes about 2 seconds and I think its too much.

Agreed.

> SELECT id, name, id2, name2 GROUP BY id ORDER BY name2, year DESC LIMIT 0,
> 15

None of your indexes are much use for this SELECT command.  Imagine trying to 
do the SELECT command yourself and you'll quickly see that whichever of the 
supplied indexes you use you're left trying to sort a great deal of records by 
hand.  A good index would be

name2, year, id

That's all three columns in the same index, not three separate indexes one on 
each column.

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

Reply via email to