Re: Bad row estimates

Поиск
Список
Период
Сортировка
От Jim C. Nasby
Тема Re: Bad row estimates
Дата
Msg-id 20060304154605.GC80721@pervasive.com
обсуждение исходный текст
Ответ на Re: Bad row estimates  (Greg Stark <gsstark@mit.edu>)
Список pgsql-performance
On Sat, Mar 04, 2006 at 02:01:35AM -0500, Greg Stark wrote:
> Alex Adriaanse <alex@innovacomputing.com> writes:
>
> > SELECT count(*) FROM test_table_1
> >     INNER JOIN test_table_2 ON
> >         (test_table_2.s_id = 13300613 AND test_table_1.id = test_table_2.n_id)
> >     WHERE now() BETWEEN test_table_1.start_ts AND test_table_1.end_ts
> >     AND test_table_1.id = test_table_1.g_id;

Something else that helps in cases like this is to place both an upper
and lower boundary on one (or both) fields if possible. For example, if
you know that start_ts and end_ts will always be within 1 hour of each
other, adding the following will help:

AND start_ts >= now()-'1 hour'::interval AND end_ts <= now()+'1
hour'::interval
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461

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

Предыдущее
От: "hubert depesz lubaczewski"
Дата:
Сообщение: Re: How to query and index for customer with lastname and city
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Bad row estimates