Steve Green <[EMAIL PROTECTED]> wrote: [...] > > select u_id, sum( data1 ), sum( data2 ) > from data where utime >= 1146441600 and utime < 1149120000 > group by u_id > order by sum( data1 ) desc > limit 10 > [...] > > So, is there a way that I can get sqlite to use the optimal index > without having to remove my unique index?
Have you run ANALYZE. That might fix it. If not, try adding a unary + in front of the two utime terms in the WHERE clause: WHERE +utime >= 1145441600 AND +utime < 1149120000 If you can send me some sample data and queries, that would be great. It will help me to improve the optimizer so that these kinds of things come up less often in the future. -- D. Richard Hipp <[EMAIL PROTECTED]>