Sub topic 1
What you are choosing for: workload types and data scale
Choosing a data tool starts with two facts about your situation: what kind of work you do, and how big the data is compared with the machine you have. This chapter gives you a way to describe both. Later chapters compare the four tools against these descriptions.
Prerequisites
This chapter assumes you have:
- Basic Python, including functions and imports.
- Familiarity with tabular data: rows, columns, and data types.
- Basic SQL: SELECT, WHERE, GROUP BY, and JOIN.
- Some experience loading and transforming a dataset with pandas or SQL.
You do not need to have used Polars, DuckDB, or Spark yet. The code here needs pandas and pyarrow.
Why start with the workload
Most tool debates are really arguments about different workloads. A person who explores a 50 MB CSV in a notebook and a person who rebuilds a 4 TB event table every night both say "data processing", and they need very different things. Describing your workload first keeps you from picking a tool because of a benchmark that measured something else.
Two questions drive the rest of the tutorial:
- What shape is the work: exploratory, repeated, SQL-heavy, or model-oriented?
- How large is the data once it is in memory, compared with the RAM on the machine that will run it?
Workload types
The same dataset can be used in several ways. These are the common patterns, and what each one asks of a tool.
| Workload | Typical pattern | What matters most |
|---|---|---|
| Interactive exploration | Load, inspect, filter, plot, repeat in a notebook | Fast feedback, a rich ecosystem, forgiving syntax |
| Batch ETL | Read files, clean and join, write files on a schedule | Throughput, predictable memory, reliability |
| Analytical queries | Filters, group-bys, and joins over wide tables, often written in SQL | Scan speed, column pruning, join performance |
| Feature preparation for ML | Row-wise and window transformations feeding a model library | Interoperability with NumPy and scikit-learn style tools |
| Shared, many-user analytics | Several jobs or people on the same data at once | Concurrency, resource isolation, governance |
Three properties of a workload change the answer more than the label does:
- Repetition. Code you run once can be slow and wasteful. Code that runs every hour pays for its inefficiency every hour.
- Operation mix. Scans, filters, and aggregations over a few columns behave differently from many-to-many joins or full sorts. Joins and sorts need more memory and, on a cluster, more network traffic.
- Latency target. A person waiting at a notebook cell wants seconds. A nightly job can take an hour.
Data scale
"Big data" is not a useful category. A more useful question is how the data compares with your machine.
File size is not memory size
A Parquet file is compressed and stores each column separately. Loaded into a pandas DataFrame, the same data is usually several times larger. The ratio depends on the data:
- Text columns can expand a lot, because Python string objects carry overhead.
- Columns with few distinct values, such as country codes, compress well on disk but are large in memory unless you convert them to a category type.
- A CSV is uncompressed text, so its file size is a rough but unreliable guide.
Operations also need working space. A sort, a join, or a group-by can create copies or intermediate results. A common planning rule is to leave several times the data size free for eager, in-memory work. The exact multiple depends on the operation and the tool, so treat it as a margin, not a measurement.
Estimate before you decide
Measure a sample and extrapolate. This script reads one batch of rows from a Parquet file, measures its in-memory size with pandas, and scales by the total row count stored in the file metadata.
import pyarrow.parquet as pq
pf = pq.ParquetFile("sales.parquet")
total_rows = pf.metadata.num_rows
sample = next(pf.iter_batches(batch_size=100_000)).to_pandas()
bytes_per_row = sample.memory_usage(deep=True).sum() / len(sample)
estimate_gb = bytes_per_row * total_rows / 1e9
print(f"{total_rows:,} rows, about {estimate_gb:.1f} GB as a pandas DataFrame")deep=True matters. Without it, pandas counts only the pointer for each string and reports a much smaller number than the real memory use.
Three scale bands
Compare the estimate with the RAM you have. These bands are heuristics for planning, not hard limits.
| Band | Condition | What it usually means |
|---|---|---|
| Comfortable | In-memory size is small relative to RAM, with room for copies | Every single-machine tool works. Pick on ergonomics and speed. |
| Tight or larger than memory | Data fits on local disk but not comfortably in RAM | Eager, all-in-memory loading becomes risky. Engines that stream or spill to disk become attractive. |
| Beyond one machine | Data or compute needs exceed one machine's disk, RAM, or acceptable runtime | Distributed processing becomes a candidate, with its operational costs. |
Edge cases that shift the band
The headline size hides several details that can move a dataset from one band to another.
- Width versus length. A table with 20 columns and 500 million rows and a table with 2,000 columns and 5 million rows can have the same size. Queries that touch few columns benefit from columnar storage in the first case far more than in the second.
- Growth. A dataset that fits today may not in six months. Ask how fast it grows before you commit to a tool whose limit you will soon reach.
- Many small files. Thousands of tiny files cost time in listing and opening them, even if the total size is small. Compacting them is often a better fix than changing tools.
- Intermediate results. A join that multiplies rows can produce an intermediate table far larger than either input. Estimate the output of the largest step, not only the input.
- Concurrency. One analyst on a laptop is a different problem from twenty scheduled jobs sharing one server, even at the same data size.
Putting it together
Write your situation as a short profile. For example: "Batch ETL, run nightly, joins on a 60 GB input, one 128 GB server, input growing about 20% per quarter." That sentence already rules some options in and others out, and it gives you something concrete to test in the benchmarking chapter. The following chapters describe how each tool executes work, so you can match its behavior to a profile like this one.
Exercise
A Parquet file is 3 GB on disk and holds 200 million rows. A 100,000-row sample takes 120 MB in pandas when measured with memory_usage(deep=True). Your laptop has 16 GB of RAM. Estimate the in-memory size, name the scale band, and say what you would try before changing tools.
Show answer
The sample uses 120 MB / 100,000 rows = 1,200 bytes per row. For 200 million rows that is about 240 GB, far above 16 GB, so loading the whole file into pandas will fail on this laptop. That puts the dataset in the tight or larger-than-memory band for a laptop, and possibly beyond one machine if you also lack the disk or time. Before changing tools, check how much you can reduce it: read only the needed columns, filter early, use narrower types, and convert repeated strings to categories. If the sample is dominated by a few wide string columns, dropping them could shrink the estimate a lot. Also check that the first 100,000 rows are representative, since the real size could be higher or lower.