Skip to content
The planner · drill

The rare value and the common one

Return the ids of every 'error' event, oldest first. There are far fewer of these than of any other kind, and the plan should reflect that.

Tables in this database · Events
CREATE TABLE events (
  id INTEGER PRIMARY KEY,
  actor_id INTEGER NOT NULL,
  kind TEXT NOT NULL,
  email TEXT NOT NULL,
  happened_on DATE NOT NULL,
  duration_ms INTEGER
)
CREATE INDEX events_actor_idx ON events (actor_id);
CREATE INDEX events_kind_happened_idx ON events (kind, happened_on);
CREATE INDEX events_email_idx ON events (email);

Your query

⌘⏎