Hacker News new | ask | show | jobs
by vivzkestrel 908 days ago
CREATE INDEX IF NOT EXISTS feed_items_pubdate_id ON public.feed_items USING btree (pubdate DESC NULLS FIRST, id DESC NULLS FIRST) TABLESPACE pg_default;

create an index on both the pubdate (timestamptz column with potential duplicates like your post mentions) and a uuid primary key column (id in my case) problem solved

1 comments

There are a couple of shortcomings that I think I see:

1. If the clock moves backwards (and an "older" record gets created), it doesn't help.

2. If a duplicate timestamp is created with an id that sorts earlier than one of the other dups (and a user has already synced to the first dup).

In both of those cases, the user won't receive the new record. (Yes, neither is probable, but neither is impossible.)