Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
> On Wed, 9 Apr 2003, Cris wrote:
>> I've created an index on (id,op,tt) to improve the next query, that is executed very often:
>> "SELECT * FROM BB WHERE id="+ id+" AND op=0 order by tt desc;";
>> (because the only row I need is the one that has the highest tt)
> You might want to use limit 1 then to prevent it from getting all the rest
> of the rows as well.
Also, I think you'll need to say "ORDER BY id, op, tt" to get it to
realize that the index matches the required ordering.
regards, tom lane