A Python package to benchmark query performance and comparison on PostgreSQL Database
Project description
pgbenchmark
pgbenchmark is a Python package to benchmark query performance on a PostgreSQL database. It allows you to measure the
execution time of queries over multiple runs, providing detailed metrics about each run's performance.
[--- UNDER DEVELOPMENT ---]
Getting Started
pip install pgbenchmark
import psycopg2
from pgbenchmark import Benchmark
# Connect to PostgreSQL
conn = psycopg2.connect(
dbname="",
user="",
password="",
host="",
port=""
)
# Create benchmark instance with desired number of Runs
num_runs = 100_000
# Create a Benchmark class
benchmark = Benchmark(db_connection=conn, number_of_runs=num_runs)
# Set .SQL file to fetch the query from for Benchmark
benchmark.set_sql("./test.sql")
# Or directly pass Raw SQL query
# benchmark.set_sql("SELECT 1;")
# Run the benchmark
benchmark.execute_benchmark()
# Get execution time summary
print("Execution Summary:", benchmark.get_execution_results())
# -----------------------------------------------
# Get execution timeseries using the generator
# (Useful if you want to visualize it as a table.
# "sent_at" is timestamp where `cursor.execute()` was initiated
for execute_data in benchmark.get_execution_timeseries():
print(execute_data['sent_at'], execute_data['duration'])
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 Distribution
Built Distribution
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 pgbenchmark-0.0.3.tar.gz.
File metadata
- Download URL: pgbenchmark-0.0.3.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
615e92ec12ee37962c4df85299bb7f1bb7a0daba214939cc03a334a9bb007725
|
|
| MD5 |
aac03ec6670ddd9419e98c873188915a
|
|
| BLAKE2b-256 |
9fa3de8862b25f835d05714e11daecc8bc2a1452eb43c7cfcde62af1aebbc6f9
|
File details
Details for the file pgbenchmark-0.0.3-py3-none-any.whl.
File metadata
- Download URL: pgbenchmark-0.0.3-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72e8f69f11327e178e042f20f5e0db99c923badf6c3e787b3dcd0af096c4b03c
|
|
| MD5 |
eca9febda5cf4e9e3b89ccf314405281
|
|
| BLAKE2b-256 |
3a457b71f0d0002192ea996cb24e0aa6259028379b18f9d8e56c68e7a4d5ebe3
|