Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Choose PostgreSQL Indexing Strategies
00:00
5 left

Choose PostgreSQL Indexing Strategies

HardSQL · PostgreSQL

Problem

A PostgreSQL system contains entity, record, and event data with JSONB attributes, status values, and timestamp-based access patterns. Create the recommended indexes for these workload patterns, then return their catalog definitions.

Output

  1. Return one row per requested index.
  2. Return columns index_name and index_definition.
  3. Include the five requested indexes, ordered alphabetically by index name.
  4. The index definitions must show the verification schema used by the PostgreSQL catalog.

Schema

entities
ColumnTypeDescription
entity_idPKINTEntity identifier
external_codeVARCHAR(40)Unique external lookup code
entity_typeVARCHAR(30)Entity classification
attributesJSONBFlexible entity attributes
records
ColumnTypeDescription
record_idPKINTRecord identifier
entity_idINTReferenced entity
statusVARCHAR(20)Record status
created_atTIMESTAMPRecord creation timestamp
payloadJSONBRecord payload
events
ColumnTypeDescription
event_idPKINTEvent identifier
record_idINTReferenced record
event_typeVARCHAR(30)Event classification
occurred_atTIMESTAMPEvent timestamp
detailsJSONBEvent details
Tablesentitiesrecordsevents
Interviewer

Your question is Choose PostgreSQL Indexing Strategies. Start with the requirements and the three 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.