[MASSMAIL]Allowing DESC for a PRIMARY KEY column

Поиск
Список
Период
Сортировка
От Mitar
Тема [MASSMAIL]Allowing DESC for a PRIMARY KEY column
Дата
Msg-id CAKLmikNCFD44VjzRCRwuiVWDOE=T7zsOzygd5XakKNdRgLv-Aw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Allowing DESC for a PRIMARY KEY column  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi!

I have the same problem as [1]. I have table something like:

CREATE TABLE values (
  id int NOT NULL,
  revision int NOT NULL,
  data jsonb NOT NULL,
  PRIMARY KEY (id, revision)
)

And I would like to be able to specify PRIMARY KEY (id, revision DESC)
because the most common query I am making is:

SELECT data FROM values WHERE id=123 ORDER BY revision DESC LIMIT 1

My understanding, based on [2], is that the primary key index cannot
help here, unless it is defined with DESC on revision. But this does
not seem to be possible. Would you entertain a patch adding this
feature? It seems pretty straightforward?


Mitar

[1] https://stackoverflow.com/questions/45597101/primary-key-with-asc-or-desc-ordering
[2] https://www.postgresql.org/docs/16/indexes-ordering.html

-- 
https://mitar.tnode.com/
https://twitter.com/mitar_m
https://noc.social/@mitar



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Why is parula failing?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Allowing DESC for a PRIMARY KEY column