skewsplit
skewsplit reads a database column's distribution and returns balanced,
index-friendly range predicates for the predicates argument of Spark's JDBC
reader, together with a report of the remaining skew.
For PostgreSQL, it plans from the column's statistics in pg_stats, without
scanning the table. NULL rows get their own predicate, a value too frequent
to split gets its own col = value predicate, and the predicates match every
row exactly once whatever the data.
Status: early development (pre-alpha). The API can change in any 0.x release.
Install
pip install "skewsplit[postgres]"
The postgres extra installs psycopg, which also needs libpq: add
psycopg[binary] if your system has none.
Use
from skewsplit import postgres
plan = postgres.plan("host=db dbname=shop user=reader", "public.orders", "customer_id", 16)
print(plan.report)
df = spark.read.jdbc(url, "public.orders", predicates=plan.predicates, properties=properties)
The planner itself needs no database:
>>> import skewsplit
>>> plan = skewsplit.plan(
... {
... "column": "customer_id",
... "type": "int4",
... "null_rows": 100,
... "mcv": [{"value": "7", "rows": 60}, {"value": "42", "rows": 500}],
... "histogram": {"bounds": ["1", "250", "500", "750", "1000"], "rows": 400},
... },
... 4,
... )
>>> for predicate in plan.predicates:
... print(predicate)
"customer_id" IS NULL
"customer_id" < 42
"customer_id" = 42
"customer_id" > 42 AND "customer_id" < 520
"customer_id" >= 520
From the command line, skewsplit plan --table public.orders --column customer_id --partitions 16 prints the same report, and --format pyspark
prints the code that reads the table.
The output contains real values from the column: treat plans, reports and logs like the data they describe.
The repository has the full documentation: the command line, when to use hash-mod instead, limitations and supported versions.
Metadata
Release files for skewsplit 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| skewsplit-0.1.0.tar.gz | 36.5 kB | With provenance | Details for skewsplit-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| skewsplit-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for skewsplit-0.1.0-py3-none-any.whl |
Total release size: 80.8 kB
Release files / skewsplit-0.1.0.tar.gz
| Download URL | skewsplit-0.1.0.tar.gz |
|---|---|
| Size | 36.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d9e1044e423bf7697602f05e435a57c761ce4cd97249160ddd315e7fc357e262
|
|
BLAKE2b-256 checksum How to use checksums |
8ff72bb973d3cf1ab56a5a1fc4eae84e9a226dad8c9a61001bbffa279c1558cc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logRelease files / skewsplit-0.1.0-py3-none-any.whl
| Download URL | skewsplit-0.1.0-py3-none-any.whl |
|---|---|
| Size | 44.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9a97de185e28f5ffb365f53d83ad9e7516d187f338e28285bae1c740d4fcd9a4
|
|
BLAKE2b-256 checksum How to use checksums |
1f00322142fcfef4ea22af3bcd4ea8668712001870e1ad773e380c8e374771f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logSecurity for skewsplit 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for skewsplit-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.