Peak Telemetry Readings and Warehouse Modeling

Medium · Data Manipulation (SQL/Python) · Data Engineer · Technical Screen

Problem Statement

A data engineering technical screen covers three topics across SQL set logic, windowed analytics, and dimensional modeling. The automated SQL runner grades Part 2, while Parts 1 and 3 are open-ended discussion prompts you should also be ready to explain.

Part 1 — Set Operations and Anti-Joins

Suppose a warehouse holds two tables, active_sensors and backup_sensors, and each table has a nullable integer column sensor_id.

  1. Compare UNION and UNION ALL in terms of execution cost, memory usage, and data movement. When should you choose each operator in a large analytical warehouse?
  2. Write a SQL query that outputs every non-NULL sensor_id present in active_sensors that does not appear in backup_sensors. Make sure your query stays accurate even when either table contains NULL values.

Part 2 — Top-3 Readings per Sensor (Graded SQL Query)

Using the sensor_readings table defined below, write a SQL query that returns up to the 3 largest non-NULL reading_value measurements recorded for each sensor_id during the preceding 24 hours.

Apply these exact evaluation rules:

  • Fix the current reference time at 2023-10-01 12:00:00. A reading falls inside the 24-hour window when its timestamp lies between 2023-09-30 12:00:00 and 2023-10-01 12:00:00, inclusive of both endpoints.
  • Discard any row where reading_value is NULL.
  • For each sensor_id, rank valid in-window rows from highest reading_value to lowest. When two rows for the same sensor have identical reading_value numbers, favor the row with the later timestamp.
  • Output at most 3 rows per sensor_id (even if exact duplicate rows exist). If a sensor has only 1 or 2 qualifying rows, output all of them; if it has none, omit that sensor.
  • Return columns sensor_id, reading_value, and timestamp in any row order.

Part 3 — Telemetry Warehouse Modeling

You are designing the analytical storage layer for high-frequency device telemetry.

  1. Contrast a fact table with a dimension table inside a star schema.
  2. Suppose a physical sensor receives a field servicing upgrade that changes descriptive attributes (such as mounting site or hardware vendor) while keeping the same sensor_id. Explain how to track full historical accuracy using a Type 2 Slowly Changing Dimension (SCD Type 2).

Input Schema

sensor_readings

Column Type Description
sensor_id INTEGER Identifier of the telemetry device
reading_value DOUBLE Recorded numeric measurement (may be NULL)
timestamp TIMESTAMP Measurement time formatted as 'YYYY-MM-DD HH:MM:SS'

Examples

Example 1

Input (sensor_readings):

sensor_id reading_value timestamp
10 88.0 2023-09-29 18:00:00
10 NULL 2023-10-01 11:30:00
10 74.5 2023-10-01 08:15:00
10 71.0 2023-09-30 19:00:00
10 71.0 2023-10-01 09:45:00
10 68.2 2023-10-01 10:20:00
20 42.8 2023-09-30 12:00:00
20 45.3 2023-10-01 12:00:00

Expected Output:

sensor_id reading_value timestamp
10 74.5 2023-10-01 08:15:00
10 71.0 2023-10-01 09:45:00
10 71.0 2023-09-30 19:00:00
20 45.3 2023-10-01 12:00:00
20 42.8 2023-09-30 12:00:00

Walk-through: For sensor 10, 88.0 happened prior to 2023-09-30 12:00:00 and the 11:30:00 row is NULL, so both are excluded before ranking; of the remaining four valid measurements (74.5, 71.0, 71.0, 68.2), the top three are kept and 68.2 is dropped. For sensor 20, both timestamps sit right on the inclusive 24-hour boundaries, and since there are only two valid rows, both are returned.

Example 2

Input (sensor_readings):

sensor_id reading_value timestamp
30 60.0 2023-10-01 06:00:00
30 55.0 2023-10-01 07:00:00
30 55.0 2023-10-01 09:30:00
30 55.0 2023-10-01 08:15:00
40 91.0 2023-10-01 12:00:01

Expected Output:

sensor_id reading_value timestamp
30 60.0 2023-10-01 06:00:00
30 55.0 2023-10-01 09:30:00
30 55.0 2023-10-01 08:15:00

Walk-through: Sensor 30 has a three-way tie at 55.0 behind 60.0; ordering tied values by timestamp descending retains the 09:30:00 and 08:15:00 rows while dropping 07:00:00. Sensor 40's sole measurement is one second past 2023-10-01 12:00:00, so sensor 40 produces zero rows.

Constraints

  • timestamps are formatted as ISO strings 'YYYY-MM-DD HH:MM:SS' in the same UTC clock as the reference timestamp '2023-10-01 12:00:00'.
  • reading_value may be negative, zero, positive, or NULL.
  • sensor_readings may be empty and may contain duplicate (sensor_id, reading_value, timestamp) rows; each sensor_id must never appear more than 3 times in the result.
  • Result rows may be returned in any order, with exact column names sensor_id, reading_value, timestamp.

Step-by-step walkthrough

  1. Understand the three parts and the graded query

    This interview prompt covers three core data engineering areas: SQL set operations (Part 1), top-N-per-group analytics (Part 2), and dimensional warehouse modeling (Part 3).

    The automated judge runs Part 2 against sensor_readings(sensor_id, reading_value, timestamp). Let us build that query step by step first, and then walk through crisp, interview-ready answers for Parts 1 and 3 right before the final submission.

    Here are the exact rules for Part 2:

    • "Now" is fixed at 2023-10-01 12:00:00, so the last 24 hours is the inclusive window [2023-09-30 12:00:00, 2023-10-01 12:00:00].
    • Rows where reading_value is NULL must be ignored.
    • Return at most 3 rows per sensor_id with columns sensor_id, reading_value, timestamp.
    • If two readings for the same sensor have the same reading_value, prefer the more recent timestamp.
    • If a sensor has only 1 or 2 valid readings in the window, return all of them; if it has 0, return none. Row order does not matter.
  2. Why GROUP BY and LIMIT fall short

    Beginners usually reach for GROUP BY or LIMIT 3 first, and both hit a wall:

    -- Wrong: collapses each sensor down to 1 row instead of keeping its top 3
    SELECT sensor_id, MAX(reading_value)
    FROM sensor_readings
    GROUP BY sensor_id;
    
    -- Wrong: keeps 3 rows across the ENTIRE table instead of 3 per sensor
    SELECT sensor_id, reading_value, timestamp
    FROM sensor_readings
    ORDER BY reading_value DESC
    LIMIT 3;
    

    What we actually want is to keep every individual reading row intact while attaching a per-sensor rank (1, 2, 3, ...) to each row. That is the exact job of a window function—a SQL calculation (OVER (...)) that looks across a related group of rows and adds a computed column without collapsing rows together.

    To keep our query easy to read, we will also organize it with Common Table Expressions (CTEs)—named temporary steps introduced with WITH step_name AS (...) that read from top to bottom like variables in code.

  3. Filter the 24-hour window and NULLs before ranking

    The order of operations is crucial: we must discard out-of-window rows and NULL values before numbering each sensor's readings.

    Why? Suppose sensor 10 recorded 88.0 on September 29 and 74.5 today (as in Example 1). If we numbered all historical rows first, 88.0 would take rank 1 and 74.5 would drop to rank 2; filtering to the last 24 hours afterward would throw away rank 1 and leave sensor 10 with only two rows instead of three!

    Raw rows for sensor 10 (Example 1):
      (10, 88.0, '2023-09-29 18:00:00')  --> outside 24h window -> drop first!
      (10, NULL, '2023-10-01 11:30:00')  --> NULL reading       -> drop first!
      (10, 74.5, '2023-10-01 08:15:00')  --> valid -> survives into ranking
      (10, 71.0, '2023-10-01 09:45:00')  --> valid -> survives into ranking
    

    Filtering reading_value IS NOT NULL in WHERE also protects us across SQL engines: SQLite treats NULL as smaller than any number (so ORDER BY reading_value DESC puts NULL last), whereas PostgreSQL treats NULL as larger than any number by default and would put NULL at rank 1!

    Because ISO timestamps formatted as YYYY-MM-DD HH:MM:SS sort chronologically from left to right, >= and <= include both endpoints cleanly:

    WITH recent_readings AS (
        -- Step 1: Filter out NULL values and out-of-window timestamps BEFORE ranking
        -- so old spikes or missing readings can never consume a sensor's top-3 slots.
        -- Both endpoints of [2023-09-30 12:00:00, 2023-10-01 12:00:00] are inclusive.
        SELECT
            sensor_id,
            reading_value,
            timestamp
        FROM sensor_readings
        WHERE reading_value IS NOT NULL
          AND timestamp >= '2023-09-30 12:00:00'
          AND timestamp <= '2023-10-01 12:00:00'
    ),
    
  4. Number each sensor's readings with ROW_NUMBER

    SQL offers three ranking window functions: ROW_NUMBER(), RANK(), and DENSE_RANK(). Let us trace all three on sensor 30 from Example 2 (60.0 and a three-way tie at 55.0) to see why the choice matters:

    reading_value | timestamp           | ROW_NUMBER | RANK | DENSE_RANK
    --------------+---------------------+------------+------+-----------
    60.0          | 2023-10-01 06:00:00 |     1      |  1   |     1
    55.0          | 2023-10-01 09:30:00 |     2      |  2   |     2
    55.0          | 2023-10-01 08:15:00 |     3      |  2   |     2
    55.0          | 2023-10-01 07:00:00 |     4      |  2   |     2
    

    If we filter on rank <= 3, RANK() and DENSE_RANK() on reading_value return all 4 rows, violating "at most 3 rows per sensor" (even if you add timestamp to ORDER BY, two exact duplicate telemetry packets with the same value and timestamp would still tie in RANK() and push the count past 3). ROW_NUMBER() always assigns distinct integers 1, 2, 3, 4, guaranteeing at most 3 rows per sensor.

    Inside OVER (...): - PARTITION BY sensor_id splits rows into separate buckets—one per sensor—and restarts numbering at 1 for every sensor. - ORDER BY reading_value DESC, timestamp DESC puts the highest values first and breaks ties in favor of the newest timestamp.

    ranked_readings AS (
        -- Step 2: Assign 1, 2, 3, ... separately inside each sensor_id group.
        -- ROW_NUMBER (unlike RANK or DENSE_RANK) guarantees at most 3 rows even on exact ties,
        -- and timestamp DESC breaks equal reading_value ties in favor of the newer reading.
        SELECT
            sensor_id,
            reading_value,
            timestamp,
            ROW_NUMBER() OVER (
                PARTITION BY sensor_id
                ORDER BY reading_value DESC, timestamp DESC
            ) AS row_num
        FROM recent_readings
    )
    
  5. Keep the top three in the outer SELECT and trace Example 1

    Why can we not write WHERE row_num <= 3 directly inside ranked_readings? Because SQL's logical execution order runs WHERE before SELECT computes window functions—at the moment WHERE runs, row_num does not exist yet! Querying ranked_readings from an outer SELECT lets us filter WHERE row_num <= 3 and project only the three requested columns (leaving row_num out of the final output).

    Let us trace Example 1 from start to finish:

    After dropping (10, 88.0, '2023-09-29 18:00:00') and (10, NULL, '2023-10-01 11:30:00'),
    6 rows survive inside [2023-09-30 12:00:00, 2023-10-01 12:00:00]:
    
    sensor_id | reading_value | timestamp           | row_num | kept (row_num <= 3)?
    ----------+---------------+---------------------+---------+---------------------
       10     |     74.5      | 2023-10-01 08:15:00 |    1    | yes
       10     |     71.0      | 2023-10-01 09:45:00 |    2    | yes (newer 71.0 first)
       10     |     71.0      | 2023-09-30 19:00:00 |    3    | yes
       10     |     68.2      | 2023-10-01 10:20:00 |    4    | no
       20     |     45.3      | 2023-10-01 12:00:00 |    1    | yes
       20     |     42.8      | 2023-09-30 12:00:00 |    2    | yes
    

    Sensor 10 keeps its 3 highest valid readings (74.5 and both 71.0 rows, dropping 68.2) and sensor 20 keeps both of its boundary readings, returning 5 rows total.

  6. Part 1: UNION vs UNION ALL and NULL-safe anti-joins

    In a live technical screen, you will also answer Part 1 verbally or on the whiteboard:

    1. UNION vs UNION ALL:

      • UNION ALL simply stacks the rows of the second query underneath the first in a single streaming pass with zero deduplication overhead.
      • UNION stacks the rows and eliminates duplicates across (and within) both inputs, which forces the warehouse to build a giant hash table or sort the entire combined dataset—often spilling to disk and shuffling rows across network nodes.
      • Rule of thumb: Default to UNION ALL whenever inputs come from separate partitions/sources or when duplicates are valid event occurrences; use UNION only when you genuinely need set deduplication.
    2. Active sensors missing from backup_sensors (NULL-safe anti-join): An anti-join keeps rows from one table that have no matching row in another table. Avoid WHERE sensor_id NOT IN (SELECT sensor_id FROM backup_sensors)! Under SQL's three-valued logic (TRUE, FALSE, UNKNOWN), if backup_sensors contains even a single NULL, 1 NOT IN (2, NULL) expands to 1 <> 2 AND 1 <> NULL, which evaluates to TRUE AND UNKNOWN = UNKNOWN, causing NOT IN to return zero rows.

      Instead, use NOT EXISTS and handle NULL sensor IDs in active_sensors explicitly:

    active_sensors: [1, 2, 2, 3, NULL]
    backup_sensors: [2, NULL]
    
    - a.sensor_id = NULL -> filtered out explicitly by a.sensor_id IS NOT NULL
    - a.sensor_id = 2    -> matches b.sensor_id = 2 -> EXISTS is TRUE  -> excluded
    - a.sensor_id = 1, 3 -> no row satisfies b.sensor_id = a.sensor_id -> included!
    
    SELECT DISTINCT a.sensor_id
    FROM active_sensors AS a
    WHERE a.sensor_id IS NOT NULL
      AND NOT EXISTS (
          SELECT 1
          FROM backup_sensors AS b
          WHERE b.sensor_id = a.sensor_id
      );
    
  7. Part 3: Star schema and Slowly Changing Dimension Type 2

    For Part 3's telemetry warehouse design:

    1. Fact table vs Dimension table in a Star Schema: A star schema organizes a warehouse into one central fact table joined directly to surrounding dimension tables:

      • Fact table (fct_sensor_readings): Stores high-frequency numeric measurements or events—one row per sensor reading, holding foreign keys and numbers (reading_value). Narrow, append-only, and billions of rows long.
      • Dimension table (dim_sensor): Stores descriptive context used for WHERE filters and GROUP BY labels—location, manufacturer, firmware, install date. Wide, much smaller, and updated infrequently.
    2. Tracking a sensor overhaul with Slowly Changing Dimension Type 2 (SCD Type 2): If sensor 101 moves from "Roof A" to "Vault B" at 2023-10-01 08:00:00 without changing sensor_id, overwriting its row would wrongly make last month's roof readings look like vault readings! SCD Type 2 preserves history by storing one row per version of the sensor, each with its own warehouse-generated surrogate key (sensor_key) and half-open validity interval [valid_from, valid_to):

    dim_sensor after overhaul at 2023-10-01 08:00:00:
    
    sensor_key | sensor_id | location | manufacturer | valid_from          | valid_to            | is_current
    -----------+-----------+----------+--------------+---------------------+---------------------+-----------
       5001    |    101    | Roof A   | Acme         | 2023-01-01 00:00:00 | 2023-10-01 08:00:00 |   false
       5002    |    101    | Vault B  | OmniCorp     | 2023-10-01 08:00:00 | NULL                |   true
    

    Each reading joins to the version active at its event timestamp via d.sensor_id = r.sensor_id AND d.valid_from <= r.timestamp AND (d.valid_to IS NULL OR r.timestamp < d.valid_to) (or resolves sensor_key during ETL ingestion), keeping historical attribution 100% accurate.

  8. Complete SQL query

    Here is the complete Part 2 query ready for the SQLite judge:

    WITH recent_readings AS (
        -- Step 1: Filter out NULL values and out-of-window timestamps BEFORE ranking
        -- so old spikes or missing readings can never consume a sensor's top-3 slots.
        -- Both endpoints of [2023-09-30 12:00:00, 2023-10-01 12:00:00] are inclusive.
        SELECT
            sensor_id,
            reading_value,
            timestamp
        FROM sensor_readings
        WHERE reading_value IS NOT NULL
          AND timestamp >= '2023-09-30 12:00:00'
          AND timestamp <= '2023-10-01 12:00:00'
    ),
    ranked_readings AS (
        -- Step 2: Assign 1, 2, 3, ... separately inside each sensor_id group.
        -- ROW_NUMBER (unlike RANK or DENSE_RANK) guarantees at most 3 rows even on exact ties,
        -- and timestamp DESC breaks equal reading_value ties in favor of the newer reading.
        SELECT
            sensor_id,
            reading_value,
            timestamp,
            ROW_NUMBER() OVER (
                PARTITION BY sensor_id
                ORDER BY reading_value DESC, timestamp DESC
            ) AS row_num
        FROM recent_readings
    )
    -- Step 3: Filter on row_num in the outer query because SQL evaluates WHERE before window functions.
    SELECT
        sensor_id,
        reading_value,
        timestamp
    FROM ranked_readings
    WHERE row_num <= 3
    

    ✅ Submit now — all tests should pass.

Intuition & how it works

Think of awarding top-3 ribbons across different age divisions at a track meet. First, officials cross off anyone whose time was not recorded (NULL) or who ran yesterday instead of today (outside the 24-hour window). Next, each division lines up on its own from best score to worst—with ties broken in favor of whoever ran most recently—and receives numbered tags 1, 2, 3, 4, ... starting fresh at 1 in every division. Finally, anyone holding tag 1, 2, or 3 steps onto the podium.

The obvious beginner attempts fail because standard SQL tools operate at the wrong granularity. GROUP BY sensor_id collapses all of a sensor's readings into a single summary row, losing 2nd and 3rd place, while ORDER BY reading_value DESC LIMIT 3 applies one global cutoff across the entire table instead of 3 per sensor. Using RANK() instead of ROW_NUMBER() also breaks on ties because tied readings share the same rank and can return 4 or more rows for a single sensor.

We solve this cleanly with two Common Table Expressions (CTEs)—named temporary query steps written with WITH ... AS (...)—and a window function, which is a calculation (OVER (...)) that attaches a group-relative number to each row without collapsing rows. Walk through sensor 10 from Example 1:

Input rows for sensor 10 (window is 2023-09-30 12:00:00 .. 2023-10-01 12:00:00):
  (10, 88.0, '2023-09-29 18:00:00')  -> dropped in Step 1 (too old)
  (10, NULL, '2023-10-01 11:30:00')  -> dropped in Step 1 (NULL value)
  (10, 68.2, '2023-10-01 10:20:00')  -> kept -> row_num = 4 -> dropped in Step 3
  (10, 71.0, '2023-09-30 19:00:00')  -> kept -> row_num = 3 -> returned!
  (10, 71.0, '2023-10-01 09:45:00')  -> kept -> row_num = 2 -> returned!
  (10, 74.5, '2023-10-01 08:15:00')  -> kept -> row_num = 1 -> returned!

Filtering first keeps 88.0 and NULL from stealing rank slots, ordering by (reading_value DESC, timestamp DESC) ranks the newer 71.0 ahead of the older 71.0 (and in Example 2's three-way tie at 55.0, keeps 09:30:00 and 08:15:00 over 07:00:00), and WHERE row_num <= 3 in the outer query caps each sensor at 3 rows.

Complexity

Let N be the total number of rows in sensor_readings and W be the number of valid rows inside the 24-hour window.

  • Time: Without an index, the database scans all N rows to check the WHERE filter, then sorts the W surviving rows by (sensor_id, reading_value DESC, timestamp DESC) in O(W log W) time to assign ROW_NUMBER(), and finally scans the W ranked rows once to keep row_num <= 3, for O(N + W log W) total time. With a B-tree index (a sorted tree structure that lets the database jump straight to a value range) on timestamp, finding the 24-hour slice takes O(log N + W) instead of O(N), reducing total work to O(log N + W log W).
  • Space: O(W) temporary memory (or disk spill space) to hold and sort the W in-window rows while computing ROW_NUMBER().

An index or partition key on timestamp helps far more than an index on (sensor_id, reading_value) because a 24-hour window is a tiny slice of years of telemetry history; indexing by value first still forces the engine to wade through old high readings.

Edge cases

  • Exact boundary timestamps: Readings at 2023-09-30 12:00:00 and 2023-10-01 12:00:00 are included (>= and <=), while 2023-09-30 11:59:59 and 2023-10-01 12:00:01 are excluded.
  • NULL reading_value rows: Filtered out in recent_readings before ranking so they never occupy a top-3 slot; a sensor with only NULL readings returns 0 rows.
  • Fewer than 3 valid readings: Sensors with 1 or 2 valid rows get row_num 1 or 1..2, so all of their valid readings are returned.
  • Ties on reading_value: Broken deterministically by timestamp DESC, so four readings of 85.0 at 08:00, 09:00, 10:00, and 11:00 return the 09:00, 10:00, and 11:00 rows.
  • Exact duplicate rows (same sensor, value, and timestamp): ROW_NUMBER() still numbers them sequentially (1, 2, 3, ...), strictly capping output at 3 rows per sensor (if duplicates are network-retry artifacts rather than real measurements, use SELECT DISTINCT in recent_readings first).
  • Negative and zero values: Handled naturally by DESC sorting (-1.5 ranks higher than -5.0).
  • Empty table: Returns 0 rows with the exact column header sensor_id, reading_value, timestamp.

Common mistakes

  • Using RANK() or DENSE_RANK() instead of ROW_NUMBER(): Tied values receive the same rank, allowing a sensor with ties in the top 3 to return 4, 5, or more rows.
  • Ranking all history before filtering the 24-hour window: Old peak values grab row_num 1..3 and then get removed by the timestamp filter, leaving active sensors with fewer than 3 rows.
  • Writing WHERE row_num <= 3 inside the same SELECT as ROW_NUMBER(): SQL evaluates WHERE before window functions, causing a syntax/compilation error (misuse of aliased window function); compute row_num in a CTE first (or use QUALIFY row_num <= 3 in dialects like DuckDB, Snowflake, and BigQuery that support QUALIFY).
  • Forgetting timestamp DESC in the window ORDER BY: Without a secondary sort key, SQL chooses arbitrarily among tied reading_value rows, producing non-deterministic results.
  • Relying on default NULL sort order instead of WHERE reading_value IS NOT NULL: SQLite sorts NULL last in DESC order, whereas PostgreSQL and Oracle sort NULL first in DESC order unless NULLS LAST or an explicit IS NOT NULL filter is used.
  • Using NOT IN for Part 1's anti-join: If backup_sensors contains even a single NULL, x NOT IN (..., NULL) never evaluates to TRUE, silently returning an empty result set.

Follow-up questions

  • When two source tables are guaranteed to have no overlapping rows, how can you speed up combining them with UNION, and what caveat still applies? Switch from UNION to UNION ALL. Because UNION eliminates duplicates, the execution engine has to sort or hash the entire combined output—incurring heavy memory use and network shuffles—whereas UNION ALL streams both inputs directly with zero comparison work. The key caveat is that UNION also deduplicates rows within each individual table, so UNION ALL returns the exact same result only when the two tables share no rows with each other and neither table has internal duplicate rows (if one side can contain internal duplicates, run SELECT DISTINCT on that side alone before combining with UNION ALL).

  • How should you partition and sort sensor_readings on disk once historical volume reaches multiple petabytes? Partition the table by a coarse time unit—typically by day (toDate(timestamp)) or by month (toYYYYMM(timestamp)), keeping each partition in the tens-to-hundreds-of-gigabytes sweet spot rather than creating millions of tiny per-sensor or hourly files. Time partitioning unlocks partition pruning (skipping whole data directories whose date bounds fall outside the WHERE clause), so a 24-hour query touches at most two daily partitions instead of petabytes of history, and aging out old data becomes an instant metadata DROP PARTITION. Inside each partition, cluster/sort rows by (sensor_id, timestamp)—for example ENGINE = MergeTree PARTITION BY toDate(timestamp) ORDER BY (sensor_id, timestamp) in ClickHouse—so every sensor's time series sits contiguously on disk, compresses tightly, and groups efficiently.

  • Why does a columnar database execute this per-sensor top-3 query differently from a row-oriented OLTP engine? A columnar database (such as ClickHouse, BigQuery, or Parquet-based lakehouses, where each column is stored in its own separate file segment rather than packing full rows side by side) reads only the sensor_id, reading_value, and timestamp columns from storage, ignoring dozens of wide diagnostic or payload columns typical in production telemetry. Homogeneous column blocks also compress aggressively (delta encoding on timestamps, run-length encoding on sorted sensor_ids), run vectorized SIMD loops over arrays of values, and use per-block min/max zone maps (lightweight header summaries recording each block's minimum and maximum value) to skip out-of-window blocks without decompressing them. A row-oriented OLTP store with a B-tree index on timestamp shines for tiny point lookups, whereas a columnar engine dominates analytical scans across tens of millions of 24-hour readings—and in ClickHouse you can express the query compactly with ORDER BY sensor_id, reading_value DESC, timestamp DESC LIMIT 3 BY sensor_id.

Follow-up questions

Similar questions

More Clickhouse interview questions

All 1 Clickhouse questions →