Re: max time in a table query takes ages

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: max time in a table query takes ages
Дата
Msg-id 13737.1224769677@sss.pgh.pa.us
обсуждение исходный текст
Ответ на max time in a table query takes ages  ("Grzegorz Jaśkiewicz" <gryzman@gmail.com>)
Ответы Re: max time in a table query takes ages
Список pgsql-general
"=?UTF-8?Q?Grzegorz_Ja=C5=9Bkiewicz?=" <gryzman@gmail.com> writes:
> I have a simple query over a fairly simple query here, that scans for max
> date in a table that's fairly hudge (300M rows). there's index on that field
> that's being used, but for whatever reason, it takes ages. Ideas ?

>  select date_trunc('day', max(data)) into dt from staticstats where
> processed = false

I suppose the problem is that rows with processed = false are very few
in the upper range of data.  If so, and if you really need this to go
fast, a partial index might be worth its overhead:
    create index foo on staticstats(data) where processed = false;

            regards, tom lane

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

Предыдущее
От: Andrew Sullivan
Дата:
Сообщение: Re: Import db from 8.1.3 to 8.3.1
Следующее
От: "Grzegorz Jaśkiewicz"
Дата:
Сообщение: Re: max time in a table query takes ages