DuckDB’s ceiling is higher than most people assume — it will happily chew through hundreds of gigabytes on a decent laptop. You hit the real line in three places. One: the data doesn’t fit, even compressed — multi-terabyte lakes, or joins whose shuffle doesn’t. Two: the job is scheduled, not interactive — hourly aggregations, daily compaction, a nightly “who touched what” rollup nobody wants to babysit. Three: more than one person needs the same heavy question answered at the same time, and a laptop is a terrible shared platform. Past that line, Spark. Before that line, Spark is a payroll problem.
Same question, different engine
The password spray query from the last chapter, in DuckDB:
SELECT src_ip, count(DISTINCT username) AS users_tried
FROM read_parquet('lake/auth/*/*.parquet', hive_partitioning = true)
WHERE result = 'failure'
GROUP BY src_ip
ORDER BY users_tried DESC;
And in Spark (PySpark):
from pyspark.sql import SparkSession, functions as F
spark = SparkSession.builder.appName("cgu-soc").getOrCreate()
auth = spark.read.parquet("s3a://cgu-lake/auth/") # date= folders become a column
(auth.where(F.col("result") == "failure")
.groupBy("src_ip")
.agg(F.countDistinct("username").alias("users_tried"))
.orderBy(F.desc("users_tried"))
.show())
Almost nothing. The DuckDB query above is valid Spark SQL with the table swapped for a Parquet source — that’s the entire pitch of the lake: the SQL is the portable part. What actually changes is everything around the query. The cluster schedules your job across executors instead of threads; the shuffle — the redistribute-by-key step that makes a distributed GROUP BY work — is the expensive, failure-prone heart of the whole thing, and you will learn what spark.sql.shuffle.partitions means at some point whether you want to or not. And someone is paying for all those cores by the second, so “I’ll just rerun it” gets noticeably more expensive.
Where Spark earns its keep
Three jobs genuinely need it. Building the lake itself: parsing raw logs into Parquet on a schedule, the ETL that nobody notices until it breaks — and it breaks at terabyte scale, not megabyte scale. Big joins across months of data; “every auth event joined to every VPN session in Q3” is a shuffle you do not want on a laptop. And the table formats — Iceberg and Delta — which give you ACID transactions, time travel and schema evolution on plain files, and are what make concurrent writers and re-processing survivable instead of terrifying.
Where it doesn’t
An analyst with a question and a laptop. Spinning up a cluster to count failed logins is the data equivalent of hiring a moving company to carry a sandwich. If the question fits on one machine, the notebook on your desk is faster, cheaper and more honest, because it won’t let you hide behind cluster-shaped excuses for a slow query. Reach for distributed compute when the data demands it, not when your impatience does.
Check it
You should be able to answer these now. Try each one before you open it.
When have you actually outgrown DuckDB?
When the data or the join's shuffle won't fit on one machine, when the job is scheduled rather than interactive, or when several people need the same heavy question answered at once.
Moving the password spray query from DuckDB to Spark, what changes and what doesn't?
The SQL barely changes. What does change is everything around it: executors instead of threads, the shuffle as the expensive and fragile step, and paying for cores by the second.
Name three jobs that genuinely need Spark.
Building the lake (scheduled ETL into Parquet), big joins across months of data, and running table formats like Iceberg or Delta with concurrent writers.