I am writing an application backed by Postgres DB. The application is like a logging system, the main table is like this
create table if not exists logs
(
user_id bigint not null,
log bytea not null,
timestamp timestamptz not null default clock_timestamp() at time zone 'UTC'
);
One of the main query is to fetch all log
about a certain user_id
, ordered by timestamp desc. It would be nice that under the hood Postgres DB stores all rows about the same user_id
in one page or sequential pages, instead of scattering here and there on the disk.
As I recall from textbooks, is this the so-called "index-sequential files"? How can I guide Postgres to do that?