learning-it by example

Back to the video

What Does One Query Cost? Cost Per Query From Timings

In a made-up traffic mix, one kind of query was 2 percent of the traffic and 60 percent of the compute cost. Here is how to find it.

Video #227 ยท Data strategy

Steps in the video

  1. 0:00 What does a query cost?
  2. 0:23 The idea
  3. 0:48 Setup
  4. 1:10 The data
  5. 1:25 The traffic mix
  6. 1:53 Timing
  7. 2:36 The idle machine
  8. 3:22 What this does not show
  9. 3:50 Mistakes to avoid
  10. 4:18 My take and next steps
  11. 4:42 Recap

Files

  • cost.py (20 lines)
  • data.py (23 lines)
  • measure.py (50 lines)

Download the code (zip)

Tested with

Python 3.12.15 | duckdb==2.0.0

What this does not show

The rate, the data and the traffic mix are made up. Timings come from one busy laptop with DuckDB on two threads and moved a lot between runs. Storage, network and people are not counted.

Sources

Learning IT by Example.