Uses a window function to number the duplicates and removes everything but the first of each group.
All Snippets
A collection of code, notes, and solutions.
On Postgres 11 and later a nullable column with a default is a metadata-only change. Adding NOT NULL afterwards is the part that needs care.
Lists indexes that have never been scanned, which are pure write cost. Check against a long uptime before dropping any.
Inserts, or updates the existing row when the unique column already holds that value.
Where the disk actually went, including indexes and TOAST.
Returns one row per author with their posts nested, instead of a join that repeats the author on every row.
Twelve lines covering the case most projects add a dependency for, including cancelling a call that has not fired yet.
Runs at most once per interval but still fires once more after the last event, so the final state is never dropped.
Object.groupBy is available in current runtimes; the reduce version is the fallback for older ones.
Backs off on each failure and adds jitter, so a recovering service is not hit by every client at the same moment.
fetch has no timeout of its own. AbortSignal.timeout is the short way to give it one.
Keeps a fixed number of jobs in flight rather than firing a thousand requests at once.