SQL query preprocessor for generating optimized queries
Project description
sqlquerypp: SQL query preprocessor
sqlquerypp is a library for preprocessing SQL queries. Main purpose
is writing highly optimized queries with a simplified syntax, allowing
for both maintainability and high performance.
Limitations
Currently, only MySQL 8.4 syntax is supported.
Why preprocess SQL queries?
SQL (Structed Query Language) follows a declarative paradigm, i.e. a query explains "what should be done" not "how should it be done". This stands in contrast to imperative programming, which expresses the "how should a certain task be fulfilled" aspect.
Database systems' internals are responsible for maintaining this aspect. However, for certain and large data structures, writing down "naive" queries sometimes result in poor performance.
Supported performance optimizations
Combined UNION queries
Consider the following original query:
SELECT entity_b.*
FROM entity_b
INNER JOIN entity_a
ON entity_a.id = entity_b.entity_a_id
AND entity_a.criteria = 1337;
This is a very simplified example, but if you assume entity_b contains
a multitude of items, even correct index conditions may exhaust any DBMS' join buffer.
If network overhead is acceptable, a fitting alternative approach could be a loop on the application side (Python pseudocode):
all_matches_in_entity_b = []
for entity_a_id in [rec.id
for rec in mysql_query("SELECT id FROM entity_a "
"WHERE criteria = 1337")]:
inner_result = mysql_query("SELECT * FROM entity_b "
f"WHERE entity_a_id = {entity_a_id}")
all_matches_in_entity_b += inner_result
The following statement, which is invalid SQL, translates to a MySQL
native construct of Recursive Common Table Expression and UNION
fragments when compiled by sqlquerypp. This allows for maximal
query performance, because the inner query with reduced complexity
is still taken into account. At the same time, it grants minimal I/O
overhead as only one query is executed on the database:
combined_result (SELECT id FROM entity_a WHERE criteria = 1337) AS $id {
SELECT * FROM entity_b WHERE entity_a_id = $id;
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sqlquerypp-0.1.0a5-cp314-cp314-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: sqlquerypp-0.1.0a5-cp314-cp314-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.14, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e97ed0b7f964968e8beaa9de3ef5da3adac2131e7603cee837248edd25abe241
|
|
| MD5 |
f083ebf6ee4418b43a4985f7e4a069fa
|
|
| BLAKE2b-256 |
e5fc094af97ccab7eb76b8d42b203a490fe5fbb48099a43bf2b7463c4949f4a9
|
Provenance
The following attestation bundles were made for sqlquerypp-0.1.0a5-cp314-cp314-musllinux_1_2_x86_64.whl:
Publisher:
python-publish.yml on puzzleYOU/sqlquerypp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlquerypp-0.1.0a5-cp314-cp314-musllinux_1_2_x86_64.whl -
Subject digest:
e97ed0b7f964968e8beaa9de3ef5da3adac2131e7603cee837248edd25abe241 - Sigstore transparency entry: 781110559
- Sigstore integration time:
-
Permalink:
puzzleYOU/sqlquerypp@6a5327e26d6124e89822a120b21de708a9034412 -
Branch / Tag:
refs/tags/0.1.0a5 - Owner: https://github.com/puzzleYOU
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6a5327e26d6124e89822a120b21de708a9034412 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sqlquerypp-0.1.0a5-cp314-cp314-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: sqlquerypp-0.1.0a5-cp314-cp314-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.14, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a2502aa58cd86cf3b6c8a2017831b5bde46e00ed130c3c1f4f874f014385380
|
|
| MD5 |
3c484517589959c26c685a5a1a24f64f
|
|
| BLAKE2b-256 |
cdb6fbc65d34c0a67d164e8e0cffcc4580baf13506319e3b6472b4fb24fe8336
|
Provenance
The following attestation bundles were made for sqlquerypp-0.1.0a5-cp314-cp314-manylinux_2_28_x86_64.whl:
Publisher:
python-publish.yml on puzzleYOU/sqlquerypp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlquerypp-0.1.0a5-cp314-cp314-manylinux_2_28_x86_64.whl -
Subject digest:
8a2502aa58cd86cf3b6c8a2017831b5bde46e00ed130c3c1f4f874f014385380 - Sigstore transparency entry: 781110561
- Sigstore integration time:
-
Permalink:
puzzleYOU/sqlquerypp@6a5327e26d6124e89822a120b21de708a9034412 -
Branch / Tag:
refs/tags/0.1.0a5 - Owner: https://github.com/puzzleYOU
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6a5327e26d6124e89822a120b21de708a9034412 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sqlquerypp-0.1.0a5-cp313-cp313-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: sqlquerypp-0.1.0a5-cp313-cp313-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 2.1 MB
- Tags: CPython 3.13, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ee9c1f0e3fb8d7cd48912d8b7e236a99e170fc99063a531edb0cd84597d6d4d
|
|
| MD5 |
86fa4f0cca62bf8deff9bc3044d46651
|
|
| BLAKE2b-256 |
42abc4626f03ce307a6e61b33e744fd8a2e2b81d4b07686c3bd8927c939ff72f
|
Provenance
The following attestation bundles were made for sqlquerypp-0.1.0a5-cp313-cp313-musllinux_1_2_x86_64.whl:
Publisher:
python-publish.yml on puzzleYOU/sqlquerypp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlquerypp-0.1.0a5-cp313-cp313-musllinux_1_2_x86_64.whl -
Subject digest:
4ee9c1f0e3fb8d7cd48912d8b7e236a99e170fc99063a531edb0cd84597d6d4d - Sigstore transparency entry: 781110617
- Sigstore integration time:
-
Permalink:
puzzleYOU/sqlquerypp@6a5327e26d6124e89822a120b21de708a9034412 -
Branch / Tag:
refs/tags/0.1.0a5 - Owner: https://github.com/puzzleYOU
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6a5327e26d6124e89822a120b21de708a9034412 -
Trigger Event:
release
-
Statement type:
File details
Details for the file sqlquerypp-0.1.0a5-cp313-cp313-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: sqlquerypp-0.1.0a5-cp313-cp313-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.13, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25c91d6bca95ee7337c213b16590038bb2bbcc1cfa41d94ec44a7575fec14354
|
|
| MD5 |
477ea524c2c6f0ab5a614cf58f94ef4d
|
|
| BLAKE2b-256 |
efaad443d047ae1c633d3f38843afb1fee6fe485f1fcf747b1babe74913e8b8b
|
Provenance
The following attestation bundles were made for sqlquerypp-0.1.0a5-cp313-cp313-manylinux_2_28_x86_64.whl:
Publisher:
python-publish.yml on puzzleYOU/sqlquerypp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sqlquerypp-0.1.0a5-cp313-cp313-manylinux_2_28_x86_64.whl -
Subject digest:
25c91d6bca95ee7337c213b16590038bb2bbcc1cfa41d94ec44a7575fec14354 - Sigstore transparency entry: 781110616
- Sigstore integration time:
-
Permalink:
puzzleYOU/sqlquerypp@6a5327e26d6124e89822a120b21de708a9034412 -
Branch / Tag:
refs/tags/0.1.0a5 - Owner: https://github.com/puzzleYOU
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@6a5327e26d6124e89822a120b21de708a9034412 -
Trigger Event:
release
-
Statement type: