Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
PostgreSQL Indexing Trade-Offs
00:00
5 left

PostgreSQL Indexing Trade-Offs

HardSQL · PostgreSQL

Problem

Explain the performance trade-offs between different indexing strategies in PostgreSQL.

Compare B-tree, Hash, GIN, GiST, BRIN, multicolumn, partial, and covering indexes. Relate the choices to the representative query and explain read performance, write overhead, storage, selectivity, and maintenance considerations.

Output

  1. Return one row per qualifying asset with asset_id, owner_id, created_at, event_type, and event_time.
  2. Include active assets owned by owner_id 101 whose metadata contains {"channel": "web"}. Preserve assets without a matching event.
  3. Order by created_at descending, then asset_id ascending.

Schema

assets
ColumnTypeDescription
idPKINTAsset identifier
owner_idINTOwning account identifier
statusVARCHAR(20)Current asset status
created_atTIMESTAMPAsset creation timestamp
metadataJSONBSearchable asset metadata
asset_events
ColumnTypeDescription
idPKINTEvent identifier
asset_idINTReferenced asset
event_typeVARCHAR(30)Event classification
event_timeTIMESTAMPEvent timestamp
Tablesassetsasset_events
Interviewer

Your question is PostgreSQL Indexing Trade-Offs. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.