Re: Do BRIN indexes support MIN/MAX?

Поиск
Список
Период
Сортировка
От Vladimir Sitnikov
Тема Re: Do BRIN indexes support MIN/MAX?
Дата
Msg-id CAB=Je-HrTBzFGvR2RdAyXVm8bAFVZzteXPX=QcEiQRLvan74VA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Do BRIN indexes support MIN/MAX?  (Julien Rouhaud <rjuju123@gmail.com>)
Список pgsql-general
> so you can't deduce in which range the current min or max value is from there.

That is why you select several candidate ranges and scan the table for those ranges.

For instance, if you have ranges
1) 1..4
2) 5..8
3) 6..9

Then you do something like

select x
  from (
    select max(col) x from tab t where rowid in 5..8 or rowid in 6..9
    union all
    selext max(col) x from tab t where rowid in 1..4
  )
 limit 1

If the first two (2 and 3) ranges happen to be empty, then scanning of 1 would be needed.

Of course, it would degrade to scanning all the pages in table if all the ranges intersect or if all the rows are deleted from the table. However, it might work well in timestamp-like cases.

Vladimir

--
Vladimir

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Do BRIN indexes support MIN/MAX?
Следующее
От: David Rowley
Дата:
Сообщение: Re: Do BRIN indexes support MIN/MAX?