design partioning scheme for selecting from latest partition
В списке pgsql-general по дате отправления:
| От | Niels Jespersen |
|---|---|
| Тема | design partioning scheme for selecting from latest partition |
| Дата | |
| Msg-id | 5de5c8b614544d7ba782b15ffb12e5da@dst.dk обсуждение исходный текст |
| Ответы |
Re: design partioning scheme for selecting from latest partition
|
| Список | pgsql-general |
Hello
I have a table partitioned like this
drop table if exists s cascade;
create table s
(
version int not null,
a int,
b int
) partition by list (version);
-- Add tens of partitions
-- Load millions of rows in each partition
-- Then I want to be able to do this wothout scanning all partitions for the highest version number.
select s.* from s where s.version = (select max(version) from s);
I could add an index on the version column. But the only use would be to the newest partition, so that seems a bit like
overkill,indexing 100 of milliomns of rows.
Is there another way to do this in a cheaper way.
For now I have created a materialized view based on the select above, thus only scanning for max partition only once.
Niels Jespersen
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера