← Openai Interview Insights

Openai·Software Engineer·Onsite - System Design / Architecture·Senior

SeniorPrefer not to say
Jun 2026

Summary

Infrastructure Engineer interview at OpenAI that was pretty much one big system design session. They gave me a meaty open-ended problem and just let it run, which I wasn't fully prepared for.

Questions Asked (1)

Q1

Design a simple in-memory SQL-like query engine that supports filtering records by fields like name, age range, and ID. Walk through your data model, how you represent predicates, query execution strategy, and how you'd extend it to support AND/OR logic, sorting, and projection.

System DesignData ModelingTechnical Trade-offs
Author's notes

This one sprawled in ways I didn't expect.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining a clear data model (e.g., records as dictionaries or structs) and a predicate representation (e.g., expression tree or lambda functions). Then describe a simple execution strategy: iterate over records, apply predicates, and optionally sort/project. Finally, discuss extensibility for AND/OR, sorting, and projection, emphasizing modularity and trade-offs.

Pro tip: Emphasize that the design should be extensible and maintainable: use composable predicates and a clear separation between parsing, planning, and execution. Mention that for in-memory engines, simplicity and performance (e.g., avoiding unnecessary allocations) are key trade-offs.

1. Define the data model

Represent records as objects or dictionaries with fields like id, name, age. Consider using a schema to enforce types and enable efficient field access.

2. Represent predicates

Use a predicate interface or function that takes a record and returns a boolean. For AND/OR, compose predicates using logical combinators (e.g., AndPredicate, OrPredicate).

3. Query execution strategy

Execute by iterating over all records, applying the predicate, and collecting matches. For sorting, collect results and sort by specified fields; for projection, map each record to a subset of fields.

4. Extensibility for AND/OR, sorting, projection

Design a query object that holds a predicate tree, sort criteria, and projection list. This allows easy addition of new operators and optimizations like predicate pushdown.

5. Discuss trade-offs and optimizations

Mention trade-offs: simplicity vs. performance, e.g., full scan vs. indexing. For in-memory, consider indexing on frequently filtered fields (e.g., hash index on id) to speed up queries.

Key Points to Mention

  • Data model: records as objects/dictionaries, schema for type safety
  • Predicate representation: composable functions or expression tree
  • Execution: full scan with predicate application, optional indexing
  • AND/OR logic: composite predicates (e.g., AndPredicate, OrPredicate)
  • Sorting: collect and sort by multiple fields, stable sort considerations
  • Projection: select subset of fields, possibly with aliasing
  • Extensibility: query object with predicate, sort, projection; parser/planner separation
  • Trade-offs: simplicity vs. performance, indexing overhead, memory usage

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.