Optimizer fails?

Поиск
Список
Период
Сортировка
От Michal Mosiewicz
Тема Optimizer fails?
Дата
Msg-id 3518773E.3EC4D592@interdata.com.pl
обсуждение исходный текст
Ответы Re: [HACKERS] Optimizer fails?  (Bruce Momjian <maillist@candle.pha.pa.us>)
Re: [HACKERS] Optimizer fails?  (dg@illustra.com (David Gould))
Список pgsql-hackers
xxxx=> \d logdt

Table    = logdt
+----------------------------------+----------------------------------+-------+
|              Field               |              Type                |
Length|
+----------------------------------+----------------------------------+-------+
| dt                               | timestamp
|     4 |
+----------------------------------+----------------------------------+-------+
xxxx=> explain select * from log where dt < '19980203';
NOTICE:  QUERY PLAN:

Seq Scan on log  (cost=105832.15 size=699588 width=62)

There is an index on log table, dt field. The index is b-tree.
However it doesn't seem to be used. (Of course I have vacuumed it). The
table has about 2M records. I don't think that Seq Scan is a good idea.

Also, what if I agregate it on dt field to count(*) or sum some values.
It would be sequentially scanned, then sorted, then grouped and finally
agregated, right?

Well, sometimes it may be good enough. But if this table is big enough,
it would be wiser to use index to select ranges from the table and then
agregate those values without sorting.

Once I saw index based agregates in the TODO list, but somehow it
disappeared.

Regards,
Mike

--
WWW: http://www.lodz.pdi.net/~mimo  tel: Int. Acc. Code + 48 42 148340
add: Michal Mosiewicz  *  Bugaj 66 m.54 *  95-200 Pabianice  *  POLAND

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Jonathan Guthrie
Дата:
Сообщение: Re: [HACKERS] Postgres "in the field"
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] char types gone.