Add (user_id,date) + aircraft_type.iata indexes (audit M3) #7

Merged
ronnyandre merged 1 commit from perf/db-indexes into main 2026-06-02 23:49:32 +02:00
Owner

Stacks on #6. Continues docs/audit-2026-06.md at M3.

Migration 0005_naive_sentry.sql:

  • flight_user_id_date_idx on (user_id, date) — serves the hot filter-by-user / order-by-date query; replaces the now-redundant standalone user_id index (leftmost prefix covers user_id-only lookups). EXPLAIN QUERY PLAN confirms an index SEARCH with no separate sort step.
  • aircraft_type_iata_idx on iata — covering index for the eq(iata, …) lookups in reference search and ICAO-over-IATA aircraft enrichment.

Deliberately skipped: country columns (only leading-wildcard LIKE, un-indexable) and a tail_number index (the aircraft-detail query is always user_id-scoped, so the composite already narrows it to a small per-user set; an UPPER(TRIM(...)) expression index is overkill at personal scale).

Verified: migration applies cleanly, EXPLAIN QUERY PLAN shows both indexes used, pnpm typecheck/lint/test (40/40) pass.

Stacks on #6. Continues `docs/audit-2026-06.md` at **M3**. Migration `0005_naive_sentry.sql`: - **`flight_user_id_date_idx`** on `(user_id, date)` — serves the hot filter-by-user / order-by-date query; replaces the now-redundant standalone `user_id` index (leftmost prefix covers user_id-only lookups). `EXPLAIN QUERY PLAN` confirms an index SEARCH with **no separate sort step**. - **`aircraft_type_iata_idx`** on `iata` — covering index for the `eq(iata, …)` lookups in reference search and ICAO-over-IATA aircraft enrichment. **Deliberately skipped:** `country` columns (only leading-wildcard `LIKE`, un-indexable) and a `tail_number` index (the aircraft-detail query is always `user_id`-scoped, so the composite already narrows it to a small per-user set; an `UPPER(TRIM(...))` expression index is overkill at personal scale). Verified: migration applies cleanly, `EXPLAIN QUERY PLAN` shows both indexes used, `pnpm typecheck`/`lint`/`test` (40/40) pass.
Migration 0005_naive_sentry.sql:
- flight_user_id_date_idx on (user_id, date) — serves the hot
  filter-by-user/order-by-date query; replaces the now-redundant standalone
  user_id index (leftmost prefix covers user_id-only lookups). EXPLAIN QUERY
  PLAN confirms an index SEARCH with no separate sort step.
- aircraft_type_iata_idx on iata — covering index for the eq(iata, ...) lookups
  in reference search and ICAO-over-IATA aircraft enrichment.

Skipped country (only leading-wildcard LIKE, un-indexable) and a tail_number
index (aircraft-detail query is always user-scoped, so the composite already
narrows it; an UPPER(TRIM(...)) expression index is overkill at personal scale).

Stacks on perf/fr24-import-transaction (PR #6).
ronnyandre force-pushed perf/db-indexes from aabc2ffa95 to 7265227404 2026-06-02 23:48:46 +02:00 Compare
ronnyandre changed target branch from perf/fr24-import-transaction to main 2026-06-02 23:49:01 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ronnyandre/fliary!7
No description provided.