Skip to main content

[PLACEHOLDER] 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pgbenchmark-0.0.2.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pgbenchmark-0.0.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file pgbenchmark-0.0.2.tar.gz.

File metadata

  • Download URL: pgbenchmark-0.0.2.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for pgbenchmark-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e4271696e92142f3bdf0d5b5e1f163e7d865a8b49d5c299afb6b0b3e4b5a60f4
MD5 bb21c7901804b669d6da29c3797cd572
BLAKE2b-256 9633a013726b8afb5f82ab5508f8242ff5da5d7ae4b223966f888bd0938539ff

See more details on using hashes here.

File details

Details for the file pgbenchmark-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pgbenchmark-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for pgbenchmark-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 14ee367c174aef0d70144650b95b5e6434aaeb15bdfaeb886b949585d425af2b
MD5 9b7fe0f7b028bd943b841380e27c76f1
BLAKE2b-256 fe7ab634ca9bc4ed2c509d3483326eea8b2fc65c5d7100f4f1e2dd192bceab62

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page