Re: PostgreSQL upgraded to 8.2 but forcing index scan on query produces faster
От | Tom Lane |
---|---|
Тема | Re: PostgreSQL upgraded to 8.2 but forcing index scan on query produces faster |
Дата | |
Msg-id | 12444.1269285695@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | PostgreSQL upgraded to 8.2 but forcing index scan on query produces faster (Christian Brink <cbrink@r-stream.com>) |
Ответы |
Re: PostgreSQL upgraded to 8.2 but forcing index scan on query produces faster
Re: PostgreSQL upgraded to 8.2 but forcing index scan on query produces faster |
Список | pgsql-performance |
Christian Brink <cbrink@r-stream.com> writes: > -> Nested Loop (cost=0.01..2416.59 rows=22477 width=4) > (actual time=0.595..2.150 rows=225 loops=1) > -> Index Scan using sysstrings_pkey on sysstrings > (cost=0.00..8.27 rows=1 width=182) (actual time=0.110..0.112 rows=1 loops=1) > Index Cond: (id = 'net/Console/Employee/Day End > Time'::text) > -> Index Scan using sales_tranzdate_index on sales s > (cost=0.01..1846.40 rows=22477 width=12) (actual time=0.454..1.687 > rows=225 loops=1) > Index Cond: ((s.tranzdate >= ('2010-02-15'::date + > (sysstrings.data)::time without time zone)) AND (s.tranzdate < > ('2010-02-16'::date + (sysstrings.data)::time without time zone))) > Filter: ((NOT void) AND (NOT suspended)) The fundamental reason why you're getting a bad plan choice is the factor-of-100 estimation error here. I'm not sure you can do a whole lot about that without rethinking the query --- in particular I would suggest trying to get rid of the non-constant range bounds. You're apparently already plugging in an external variable for the date, so maybe you could handle the time of day similarly instead of joining to sysstrings for it. regards, tom lane
В списке pgsql-performance по дате отправления: