Re: No index maximum? (was Re: No merge sort?)
| От | Bruno Wolff III |
|---|---|
| Тема | Re: No index maximum? (was Re: No merge sort?) |
| Дата | |
| Msg-id | 20030315152328.GA6412@wolff.to обсуждение исходный текст |
| Ответ на | No index maximum? (was Re: No merge sort?) (Taral <taral@taral.net>) |
| Ответы |
Re: No index maximum? (was Re: No merge sort?)
|
| Список | pgsql-hackers |
On Fri, Mar 14, 2003 at 14:19:46 -0600, Taral <taral@taral.net> wrote: > Same setup, different query: > > test=> explain select max(time) from test where id = '1'; > NOTICE: QUERY PLAN: > > Aggregate (cost=5084.67..5084.67 rows=1 width=0) > -> Index Scan using idx on test (cost=0.00..5081.33 rows=1333 width=0) > > Since the index is (id, time), why isn't the index being used to > retrieve the maximum value? It looks like an index scan is being done. If the index was on (time, id) instead of (id, time), then you could get a further speed up by rewriting the query as: select time from test where id = '1' order by time desc limit 1;
В списке pgsql-hackers по дате отправления: