Re: Optimizing query
| От | Peter Eisentraut |
|---|---|
| Тема | Re: Optimizing query |
| Дата | |
| Msg-id | Pine.LNX.4.44.0311191320360.20187-100000@peter.localdomain обсуждение исходный текст |
| Ответ на | Optimizing query (Uros <uros@sir-mag.com>) |
| Список | pgsql-general |
Uros writes:
> explain SELECT count(*) as views FROM stat_views WHERE date_part('day', created) = 18;
>
> QUERY PLAN
> ------------------------------------------------------------------------------------
> Aggregate (cost=100101618.08..100101618.08 rows=1 width=0)
> -> Seq Scan on stat_views (cost=100000000.00..100101565.62 rows=20984 width=0)
> Filter: (date_part('day'::text, created) = 18::double precision)
Create an index on date_part('day', created). In 7.3 and earlier you need
to create a wrapper function and index that, in 7.4 you can index
arbitrarz expressions directly. The documentation contains more
information about that.
--
Peter Eisentraut peter_e@gmx.net
В списке pgsql-general по дате отправления: