Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions polars-dataframe/queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ hits.filter(pl.col('URL').str.contains('google')).sort('EventTime').head(10).col
hits.filter(pl.col('SearchPhrase') != '').sort('EventTime').select('SearchPhrase').head(10).collect()
hits.filter(pl.col('SearchPhrase') != '').sort('SearchPhrase').select('SearchPhrase').head(10).collect()
hits.filter(pl.col('SearchPhrase') != '').sort(['EventTime', 'SearchPhrase']).select('SearchPhrase').head(10).collect()
hits.filter(pl.col('URL') != '').group_by('CounterID').agg([pl.col('URL').str.len_chars().mean().alias('l'), pl.len().alias('c')]).filter(pl.col('c') > 100000).sort('l', descending=True).limit(25).collect()
hits.filter(pl.col('Referer') != '').with_columns(pl.col('Referer').str.replace('^https?://(?:www\\.)?([^/]+)/.*$', '${1}').alias('k')).group_by('k').agg([pl.col('Referer').str.len_chars().mean().alias('l'), pl.col('Referer').min().alias('min_referer'), pl.len().alias('c')]).filter(pl.col('c') > 100000).sort('l', descending=True).limit(25).collect()
hits.filter(pl.col('URL') != '').group_by('CounterID').agg([pl.col('URL').str.len_bytes().mean().alias('l'), pl.len().alias('c')]).filter(pl.col('c') > 100000).sort('l', descending=True).limit(25).collect()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQL counts bytes, so we should do the same

hits.filter(pl.col('Referer') != '').with_columns(pl.col('Referer').str.replace('^https?://(?:www\\.)?([^/]+)/.*$', '${1}').alias('k')).group_by('k').agg([pl.col('Referer').str.len_bytes().mean().alias('l'), pl.col('Referer').min().alias('min_referer'), pl.len().alias('c')]).filter(pl.col('c') > 100000).sort('l', descending=True).limit(25).collect()
hits.select([(pl.col('ResolutionWidth') + i).sum().alias(f'c_{i}') for i in range(90)]).collect()
hits.filter(pl.col('SearchPhrase') != '').group_by(['SearchEngineID', 'ClientIP']).agg([pl.len().alias('c'), pl.sum('IsRefresh').alias('IsRefreshSum'), pl.mean('ResolutionWidth').alias('AvgResolutionWidth')]).sort('c', descending=True).head(10).collect()
hits.filter(pl.col('SearchPhrase') != '').group_by(['WatchID', 'ClientIP']).agg([pl.len().alias('c'), pl.sum('IsRefresh').alias('IsRefreshSum'), pl.mean('ResolutionWidth').alias('AvgResolutionWidth')]).sort('c', descending=True).head(10).collect()
Expand Down
60 changes: 60 additions & 0 deletions polars-dataframe/results/20261127/c6a.metal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"system": "Polars (DataFrame)",
"date": "2026-11-27",
"machine": "c6a.metal",
"cluster_size": 1,
"proprietary": "no",
"hardware": "cpu",
"tuned": "no",
"tags": ["column-oriented","dataframe","in-memory"],
"load_time": 2,
"data_size": 58970980436,
"concurrent_qps": 6.407,
"concurrent_error_ratio": 0,
"startup_time": 1.14,
"result": [
[55.948, 0.002, 0.002],
[55.939, 0.006, 0.011],
[55.927, 0.009, 0.008],
[55.919, 0.01, 0.011],
[56.027, 0.11, 0.071],
[56.082, 0.162, 0.147],
[55.917, 0.013, 0.009],
[55.941, 0.013, 0.012],
[56.15, 0.216, 0.187],
[56.193, 0.212, 0.227],
[56.034, 0.087, 0.07],
[56.017, 0.084, 0.068],
[56.058, 0.157, 0.142],
[56.11, 0.169, 0.162],
[56.08, 0.154, 0.153],
[56.093, 0.134, 0.103],
[56.303, 0.362, 0.348],
[56.299, 0.379, 0.36],
[56.595, 0.651, 0.614],
[55.898, 0.01, 0.012],
[56.069, 0.116, 0.072],
[56.085, 0.124, 0.091],
[56.185, 0.192, 0.166],
[56.031, 0.097, 0.087],
[55.931, 0.029, 0.024],
[55.945, 0.039, 0.029],
[55.971, 0.039, 0.033],
[56.004, 0.049, 0.048],
[56.439, 0.438, 0.422],
[55.925, 0.025, 0.024],
[56.031, 0.092, 0.085],
[56.057, 0.117, 0.109],
[56.698, 0.744, 0.662],
[56.651, 0.71, 0.688],
[56.704, 0.807, 0.712],
[56.011, 0.088, 0.077],
[55.97, 0.055, 0.053],
[55.964, 0.042, 0.036],
[55.97, 0.027, 0.025],
[56.012, 0.066, 0.07],
[56.012, 0.027, 0.027],
[55.98, 0.028, 0.025],
[55.991, 0.026, 0.021]
]
}
60 changes: 60 additions & 0 deletions polars-dataframe/results/20261127/c7a.metal-48xl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"system": "Polars (DataFrame)",
"date": "2026-11-27",
"machine": "c7a.metal-48xl",
"cluster_size": 1,
"proprietary": "no",
"hardware": "cpu",
"tuned": "no",
"tags": ["column-oriented","dataframe","in-memory"],
"load_time": 3,
"data_size": 58970980436,
"concurrent_qps": 11.747,
"concurrent_error_ratio": 0,
"startup_time": 1.001,
"result": [
[55.889, 0.003, 0.002],
[55.924, 0.004, 0.004],
[55.919, 0.005, 0.004],
[55.917, 0.005, 0.006],
[56.007, 0.071, 0.074],
[55.999, 0.094, 0.07],
[55.894, 0.005, 0.004],
[55.971, 0.012, 0.009],
[56.125, 0.184, 0.158],
[56.15, 0.198, 0.201],
[55.989, 0.072, 0.061],
[55.998, 0.073, 0.054],
[56.012, 0.112, 0.078],
[56.03, 0.112, 0.087],
[56.02, 0.104, 0.08],
[56.03, 0.115, 0.076],
[56.14, 0.213, 0.148],
[56.121, 0.217, 0.144],
[56.282, 0.369, 0.249],
[55.885, 0.005, 0.006],
[56.011, 0.032, 0.03],
[55.993, 0.05, 0.04],
[56.031, 0.095, 0.074],
[55.968, 0.051, 0.046],
[55.938, 0.019, 0.014],
[55.934, 0.02, 0.017],
[55.932, 0.021, 0.018],
[55.982, 0.03, 0.024],
[56.267, 0.306, 0.277],
[55.922, 0.017, 0.019],
[56.012, 0.072, 0.056],
[56.054, 0.086, 0.067],
[56.306, 0.364, 0.248],
[56.424, 0.475, 0.302],
[56.434, 0.521, 0.298],
[56.018, 0.068, 0.065],
[55.95, 0.037, 0.032],
[55.957, 0.023, 0.022],
[55.949, 0.021, 0.017],
[55.984, 0.057, 0.051],
[55.984, 0.023, 0.017],
[55.979, 0.021, 0.02],
[55.978, 0.017, 0.018]
]
}
60 changes: 60 additions & 0 deletions polars-dataframe/results/20261127/c8g.metal-48xl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"system": "Polars (DataFrame)",
"date": "2026-11-27",
"machine": "c8g.metal-48xl",
"cluster_size": 1,
"proprietary": "no",
"hardware": "cpu",
"tuned": "no",
"tags": ["column-oriented","dataframe","in-memory"],
"load_time": 3,
"data_size": 58970980436,
"concurrent_qps": 10.832,
"concurrent_error_ratio": 0,
"startup_time": 0.915,
"result": [
[55.843, 0.003, 0.002],
[55.85, 0.004, 0.003],
[55.808, 0.004, 0.004],
[55.838, 0.006, 0.006],
[55.867, 0.053, 0.033],
[55.944, 0.094, 0.065],
[55.811, 0.004, 0.004],
[55.857, 0.007, 0.007],
[55.981, 0.146, 0.142],
[56.037, 0.156, 0.136],
[55.896, 0.071, 0.06],
[55.899, 0.072, 0.059],
[55.94, 0.106, 0.075],
[55.904, 0.107, 0.083],
[55.913, 0.093, 0.071],
[55.915, 0.076, 0.053],
[56.087, 0.243, 0.176],
[56.046, 0.245, 0.169],
[56.246, 0.426, 0.31],
[55.807, 0.006, 0.006],
[55.902, 0.056, 0.055],
[55.91, 0.077, 0.071],
[55.961, 0.153, 0.111],
[55.926, 0.063, 0.063],
[55.848, 0.019, 0.017],
[55.833, 0.022, 0.022],
[55.86, 0.023, 0.019],
[55.873, 0.03, 0.027],
[56.1, 0.262, 0.254],
[55.821, 0.016, 0.015],
[55.898, 0.067, 0.053],
[55.907, 0.099, 0.066],
[56.377, 0.595, 0.323],
[56.565, 0.767, 0.413],
[56.507, 0.674, 0.383],
[55.877, 0.055, 0.044],
[55.857, 0.036, 0.03],
[55.866, 0.025, 0.022],
[55.856, 0.014, 0.016],
[55.886, 0.044, 0.043],
[55.831, 0.017, 0.015],
[55.867, 0.016, 0.016],
[55.869, 0.015, 0.014]
]
}
7 changes: 7 additions & 0 deletions polars-parquet-partitioned/benchmark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
export BENCH_DOWNLOAD_SCRIPT="download-hits-parquet-partitioned"
# Durable: the server only holds a lazy scan over the Parquet data on disk,
# and rebuilds it when it starts. The driver restarts it and drops caches
# before each cold run, and doesn't need to re-run ./load.
export BENCH_DURABLE=yes
exec ../lib/benchmark-common.sh
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions polars-parquet-partitioned/install
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

sudo apt-get update -y
sudo apt-get install -y python3-pip python3-venv

if [ ! -d myenv ]; then
python3 -m venv myenv
fi
# shellcheck disable=SC1091
source myenv/bin/activate
# Benchmark Polars 2 or newer (ClickBench#2425).
pip install --quiet 'polars>=2' pyarrow fastapi uvicorn
10 changes: 10 additions & 0 deletions polars-parquet-partitioned/load
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

# Polars uses LazyFrame (scan_parquet), so the parquet files must remain
# available for queries — we only build the plan here and DO NOT delete the
# input. /load is essentially "register the source".
elapsed=$(curl -sS -X POST http://127.0.0.1:8000/load | python3 -c 'import json,sys; print(json.load(sys.stdin)["elapsed"])')
echo "Load (server-reported): ${elapsed}s"

sync
43 changes: 43 additions & 0 deletions polars-parquet-partitioned/queries.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
hits.select(pl.len()).collect().item()
hits.filter(pl.col('AdvEngineID') != 0).select(pl.len()).collect().item()
hits.select(a_sum=pl.col('AdvEngineID').sum(), count=pl.len(), a_mean=pl.col('ResolutionWidth').mean()).collect().rows()[0]
hits.select(pl.col('UserID').mean()).collect().item()
hits.select(pl.col('UserID').n_unique()).collect().item()
hits.select(pl.col('SearchPhrase').n_unique()).collect().item()
hits.select(e_min=pl.col('EventDate').min(), e_max=pl.col('EventDate').max()).collect().rows()[0]
hits.filter(pl.col('AdvEngineID') != 0).group_by('AdvEngineID').agg(pl.len().alias('count')).sort('count', descending=True).collect()
hits.group_by('RegionID').agg(pl.col('UserID').n_unique().alias('u')).sort('u', descending=True).head(10).collect()
hits.group_by('RegionID').agg([pl.sum('AdvEngineID').alias('AdvEngineID_sum'), pl.len().alias('count'), pl.mean('ResolutionWidth').alias('ResolutionWidth_mean'), pl.col('UserID').n_unique().alias('UserID_nunique')]).sort('count', descending=True).head(10).collect()
hits.filter(pl.col('MobilePhoneModel') != '').group_by('MobilePhoneModel').agg(pl.col('UserID').n_unique()).sort('UserID', descending=True).head(10).collect()
hits.filter(pl.col('MobilePhoneModel') != '').group_by(['MobilePhone', 'MobilePhoneModel']).agg(pl.col('UserID').n_unique()).sort('UserID', descending=True).head(10).collect()
hits.filter(pl.col('SearchPhrase') != '').group_by('SearchPhrase').agg(pl.len().alias('count')).sort('count', descending=True).head(10).collect()
hits.filter(pl.col('SearchPhrase') != '').group_by('SearchPhrase').agg(pl.col('UserID').n_unique()).sort('UserID', descending=True).head(10).collect()
hits.filter(pl.col('SearchPhrase') != '').group_by(['SearchEngineID', 'SearchPhrase']).agg(pl.len().alias('count')).sort('count', descending=True).head(10).collect()
hits.group_by('UserID').agg(pl.len().alias('count')).sort('count', descending=True).head(10).collect()
hits.group_by(['UserID', 'SearchPhrase']).agg(pl.len().alias('count')).sort('count', descending=True).head(10).collect()
hits.group_by(['UserID', 'SearchPhrase']).agg(pl.len()).head(10).collect()
hits.group_by([pl.col('UserID'), pl.col('EventTime').dt.minute(), 'SearchPhrase']).agg(pl.len().alias('count')).sort('count', descending=True).head(10).collect()
hits.select('UserID').filter(pl.col('UserID') == 435090932899640449).collect()
hits.filter(pl.col('URL').str.contains('google')).select(pl.len()).collect().item()
hits.filter(pl.col('URL').str.contains('google') & (pl.col('SearchPhrase') != '')).group_by('SearchPhrase').agg([pl.col('URL').min(), pl.len().alias('count')]).sort('count', descending=True).head(10).collect()
hits.filter(pl.col('Title').str.contains('Google') & ~pl.col('URL').str.contains('.google.', literal=True) & (pl.col('SearchPhrase') != '')).group_by('SearchPhrase').agg([pl.col('URL').min(), pl.col('Title').min(), pl.len().alias('count'), pl.col('UserID').n_unique()]).sort('count', descending=True).head(10).collect()
hits.filter(pl.col('URL').str.contains('google')).sort('EventTime').head(10).collect()
hits.filter(pl.col('SearchPhrase') != '').sort('EventTime').select('SearchPhrase').head(10).collect()
hits.filter(pl.col('SearchPhrase') != '').sort('SearchPhrase').select('SearchPhrase').head(10).collect()
hits.filter(pl.col('SearchPhrase') != '').sort(['EventTime', 'SearchPhrase']).select('SearchPhrase').head(10).collect()
hits.filter(pl.col('URL') != '').group_by('CounterID').agg([pl.col('URL').str.len_bytes().mean().alias('l'), pl.len().alias('c')]).filter(pl.col('c') > 100000).sort('l', descending=True).limit(25).collect()
hits.filter(pl.col('Referer') != '').with_columns(pl.col('Referer').str.replace('^https?://(?:www\\.)?([^/]+)/.*$', '${1}').alias('k')).group_by('k').agg([pl.col('Referer').str.len_bytes().mean().alias('l'), pl.col('Referer').min().alias('min_referer'), pl.len().alias('c')]).filter(pl.col('c') > 100000).sort('l', descending=True).limit(25).collect()
hits.select([(pl.col('ResolutionWidth') + i).sum().alias(f'c_{i}') for i in range(90)]).collect()
hits.filter(pl.col('SearchPhrase') != '').group_by(['SearchEngineID', 'ClientIP']).agg([pl.len().alias('c'), pl.sum('IsRefresh').alias('IsRefreshSum'), pl.mean('ResolutionWidth').alias('AvgResolutionWidth')]).sort('c', descending=True).head(10).collect()
hits.filter(pl.col('SearchPhrase') != '').group_by(['WatchID', 'ClientIP']).agg([pl.len().alias('c'), pl.sum('IsRefresh').alias('IsRefreshSum'), pl.mean('ResolutionWidth').alias('AvgResolutionWidth')]).sort('c', descending=True).head(10).collect()
hits.group_by(['WatchID', 'ClientIP']).agg([pl.len().alias('c'), pl.sum('IsRefresh').alias('IsRefreshSum'), pl.mean('ResolutionWidth').alias('AvgResolutionWidth')]).sort('c', descending=True).head(10).collect()
hits.group_by('URL').agg(pl.len().alias('c')).sort('c', descending=True).head(10).collect()
hits.group_by('URL').agg(pl.len().alias('c')).sort('c', descending=True).with_columns(pl.lit(1).alias('1')).head(10).collect()
hits.group_by('ClientIP').agg(pl.len().alias('c')).with_columns([(pl.col('ClientIP') - 1).alias('ClientIP_minus_1'), (pl.col('ClientIP') - 2).alias('ClientIP_minus_2'), (pl.col('ClientIP') - 3).alias('ClientIP_minus_3')]).sort('c', descending=True).head(10).collect()
hits.filter((pl.col('CounterID') == 62) & (pl.col('EventDate') >= date(2013, 7, 1)) & (pl.col('EventDate') <= date(2013, 7, 31)) & (pl.col('DontCountHits') == 0) & (pl.col('IsRefresh') == 0) & (pl.col('URL') != '')).group_by('URL').agg(pl.len().alias('PageViews')).sort('PageViews', descending=True).head(10).collect()
hits.filter((pl.col('CounterID') == 62) & (pl.col('EventDate') >= date(2013, 7, 1)) & (pl.col('EventDate') <= date(2013, 7, 31)) & (pl.col('DontCountHits') == 0) & (pl.col('IsRefresh') == 0) & (pl.col('Title') != '')).group_by('Title').agg(pl.len().alias('PageViews')).sort('PageViews', descending=True).head(10).collect()
hits.filter((pl.col('CounterID') == 62) & (pl.col('EventDate') >= date(2013, 7, 1)) & (pl.col('EventDate') <= date(2013, 7, 31)) & (pl.col('IsRefresh') == 0) & (pl.col('IsLink') != 0) & (pl.col('IsDownload') == 0)).group_by('URL').agg(pl.len().alias('PageViews')).sort('PageViews', descending=True).slice(1000, 10).collect()
hits.filter((pl.col('CounterID') == 62) & (pl.col('EventDate') >= date(2013, 7, 1)) & (pl.col('EventDate') <= date(2013, 7, 31)) & (pl.col('IsRefresh') == 0)).with_columns(pl.when(pl.col('SearchEngineID').eq(0) & pl.col('AdvEngineID').eq(0)).then(pl.col('Referer')).otherwise(pl.lit('')).alias('Src')).group_by(['TraficSourceID', 'SearchEngineID', 'AdvEngineID', 'Src', 'URL']).agg(pl.len().alias('PageViews')).sort('PageViews', descending=True).slice(1000, 10).collect()
hits.filter((pl.col('CounterID') == 62) & (pl.col('EventDate') >= date(2013, 7, 1)) & (pl.col('EventDate') <= date(2013, 7, 31)) & (pl.col('IsRefresh') == 0) & pl.col('TraficSourceID').is_in([-1, 6]) & (pl.col('RefererHash') == 3594120000172545465)).group_by(['URLHash', 'EventDate']).agg(pl.len().alias('PageViews')).sort('PageViews', descending=True).slice(100, 10).collect()
hits.filter((pl.col('CounterID') == 62) & (pl.col('EventDate') >= date(2013, 7, 1)) & (pl.col('EventDate') <= date(2013, 7, 31)) & (pl.col('IsRefresh') == 0) & (pl.col('DontCountHits') == 0) & (pl.col('URLHash') == 2868770270353813622)).group_by(['WindowClientWidth', 'WindowClientHeight']).agg(pl.len().alias('PageViews')).sort('PageViews', descending=True).slice(10000, 10).collect()
hits.filter((pl.col('CounterID') == 62) & (pl.col('EventDate') >= date(2013, 7, 14)) & (pl.col('EventDate') <= date(2013, 7, 15)) & (pl.col('IsRefresh') == 0) & (pl.col('DontCountHits') == 0)).group_by(pl.col('EventTime').dt.truncate('1m').alias('M')).agg(pl.len().alias('PageViews')).sort('M').slice(1000, 10).collect()
33 changes: 33 additions & 0 deletions polars-parquet-partitioned/query
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
# Reads a polars expression from stdin, dispatches to the running
# polars server.
# Stdout: rendered result (the eval'd value as a string).
# Stderr: query runtime in fractional seconds on the last line.
# Exit non-zero on error.
set -e

query=$(cat)

tmp=$(mktemp)
status=$(curl -sS -o "$tmp" -w '%{http_code}' \
-X POST --data-binary @- http://127.0.0.1:8000/query <<<"$query")

body=$(cat "$tmp")
rm -f "$tmp"

if [ "$status" != "200" ]; then
echo "query failed: HTTP $status: $body" >&2
exit 1
fi

# Server returns {"elapsed": <seconds>, "result": "<rendered value>"}.
# Print the rendered result to stdout, elapsed to stderr.
printf '%s\n' "$body" | python3 -c '
import json, sys
o = json.load(sys.stdin)
r = o.get("result", "")
sys.stdout.write(r)
if r and not r.endswith("\n"):
sys.stdout.write("\n")
sys.stderr.write(str(o["elapsed"]) + "\n")
'
60 changes: 60 additions & 0 deletions polars-parquet-partitioned/results/20261127/c6a.2xlarge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"system": "Polars (Parquet, partitioned)",
"date": "2026-11-27",
"machine": "c6a.2xlarge",
"cluster_size": 1,
"proprietary": "no",
"hardware": "cpu",
"tuned": "no",
"tags": ["column-oriented","stateless"],
"load_time": 0,
"data_size": 14737666736,
"concurrent_qps": 0.493,
"concurrent_error_ratio": 0,
"startup_time": 1.276,
"result": [
[0.259, 0.01, 0.008],
[0.313, 0.018, 0.02],
[0.342, 0.062, 0.057],
[0.613, 0.105, 0.098],
[0.921, 0.572, 0.579],
[1.429, 1.09, 1.107],
[0.315, 0.053, 0.052],
[0.339, 0.02, 0.019],
[1.128, 0.803, 0.794],
[1.324, 1.008, 0.95],
[0.719, 0.337, 0.323],
[0.755, 0.355, 0.348],
[1.494, 1.052, 1.029],
[2.832, 1.169, 1.133],
[1.518, 1.098, 1.122],
[1.067, 0.71, 0.721],
[3.497, 2.687, 2.744],
[3.366, 2.723, 2.685],
[6.609, 4.541, 4.854],
[0.346, 0.033, 0.034],
[9.661, 1.927, 1.923],
[11.282, 2.42, 2.376],
[21.87, 4.657, 4.703],
[9.41, 1.626, 1.518],
[0.453, 0.121, 0.117],
[0.951, 0.611, 0.603],
[0.615, 0.138, 0.13],
[9.718, 1.654, 1.652],
[9.23, 7.056, 7.061],
[0.382, 0.156, 0.155],
[2.408, 0.863, 0.851],
[6.015, 1.048, 1.053],
[6.739, 3.216, 3.115],
[16.241, 11.954, 13.618],
[16.81, 12.662, 13.736],
[0.81, 0.529, 0.52],
[0.504, 0.089, 0.097],
[0.421, 0.062, 0.055],
[0.456, 0.047, 0.05],
[0.571, 0.133, 0.133],
[0.411, 0.026, 0.024],
[0.375, 0.024, 0.022],
[0.381, 0.023, 0.022]
]
}
Loading
Loading