Skip to main content

A library with the Lakehouse Framework

Project description

Query Load testing

This project is a benchmarking tool that compares query performance across different SQL Warehousing solutions.

Current support out of the box for:

  • Synapse Serverless
  • Databricks SQL Warehousing

It supports concurrent and sequential execution modes to evaluate performance, caching effects, and scalability.


⚙️ Setup

pip install query-performance-analyzer

Dependencies include:

  • pyodbc
  • azure-identity
  • databricks-sql-connector
  • PyYAML

Configure config file

The project uses a structured configuration format you can use a yaml, py, json file as you want to config it

Python

Create a config.py file:

import os

CONFIG = {
    "CONNECTIONS": {
        "Connection1": {
            "SYNAPSE_SERVER": "myysynapse-ondemand.sql.azuresynapse.net",
            "SYNAPSE_DATABASE": "my_database",
            "SOURCE": "Synapse"
        },
        "Connection2": {
            "DATABRICKS_TOKEN": os.getenv("DATABRICKS_TOKEN"),
            "DATABRICKS_SERVER": os.getenv("DATABRICKS_HOST"),
            "DATABRICKS_HTTP_PATH": "/sql/1.0/warehouses/148ccb90800933a1",
            "SOURCE": "Databricks"
        }
    },
    "QUERIES": {
        "Plan1": [
            "SELECT * FROM nikkthegreek.bronze.sales_transactions",
            "SELECT * FROM nikkthegreek.bronze.sales_transactions LIMIT 10",
            "SELECT COUNT(*) FROM nikkthegreek.bronze.sales_transactions"
        ],
        "Plan2": [
            "SELECT * FROM nikkthegreek.bronze.sales_transactions",
            "SELECT * FROM nikkthegreek.bronze.sales_transactions LIMIT 10",
            "SELECT COUNT(*) FROM nikkthegreek.bronze.sales_transactions"
        ],
        "Plan3": [
            "SELECT * FROM nikkthegreek.bronze.sales_transactions",
            "SELECT * FROM nikkthegreek.bronze.sales_transactions LIMIT 10",
            "SELECT COUNT(*) FROM nikkthegreek.bronze.sales_transactions"
        ]
    },
    "EXPERIMENTS": {
        "Experiment1": {
            "CONNECTION": "Connection1",
            "PLAN": "Plan1",
            "SEQUENTIAL_RUNS_PER_QUERY": 3,
            "PARALLEL_RUNS": 5
        },
        "Experiment2": {
            "CONNECTION": "Connection2",
            "PLAN": "Plan2",
            "SEQUENTIAL_RUNS_PER_QUERY": 2,
            "PARALLEL_RUNS": 4
        },
        "Experiment3": {
            "CONNECTION": "Connection1",
            "PLAN": "Plan3",
            "SEQUENTIAL_RUNS_PER_QUERY": 4,
            "PARALLEL_RUNS": 6
        }
    }
}

YAML

Create a config.yaml file with environment variable support:

# LakePerf Configuration - YAML Format
CONNECTIONS:
  Connection1:
    SYNAPSE_SERVER: "myysynapse-ondemand.sql.azuresynapse.net"
    SYNAPSE_DATABASE: "my_database"
    SOURCE: "Synapse"
  
  Connection2:
    DATABRICKS_TOKEN: "${DATABRICKS_TOKEN}"  # Environment variable
    DATABRICKS_SERVER: "${DATABRICKS_HOST}"   # Environment variable
    DATABRICKS_HTTP_PATH: "/sql/1.0/warehouses/148ccb90800933a1"
    SOURCE: "Databricks"

QUERIES:
  Plan1:
    - "SELECT * FROM nikkthegreek.bronze.sales_transactions"
    - "SELECT * FROM nikkthegreek.bronze.sales_transactions LIMIT 10"
    - "SELECT COUNT(*) FROM nikkthegreek.bronze.sales_transactions"
  
  Plan2:
    - "SELECT * FROM nikkthegreek.bronze.sales_transactions"
    - "SELECT * FROM nikkthegreek.bronze.sales_transactions LIMIT 10"
    - "SELECT COUNT(*) FROM nikkthegreek.bronze.sales_transactions"

EXPERIMENTS:
  Experiment1:
    CONNECTION: "Connection1"
    PLAN: "Plan1"
    SEQUENTIAL_RUNS_PER_QUERY: 3
    PARALLEL_RUNS: 5
  
  Experiment2:
    CONNECTION: "Connection2"
    PLAN: "Plan2"
    SEQUENTIAL_RUNS_PER_QUERY: 2
    PARALLEL_RUNS: 4

JSON

Create a config.json file:

{
  "CONNECTIONS": {
    "Connection1": {
      "SYNAPSE_SERVER": "myysynapse-ondemand.sql.azuresynapse.net",
      "SYNAPSE_DATABASE": "my_database",
      "SOURCE": "Synapse"
    },
    "Connection2": {
      "DATABRICKS_TOKEN": "your-databricks-token",
      "DATABRICKS_SERVER": "your-databricks-host",
      "DATABRICKS_HTTP_PATH": "/sql/1.0/warehouses/148ccb90800933a1",
      "SOURCE": "Databricks"
    }
  },
  "QUERIES": {
    "Plan1": [
      "SELECT * FROM nikkthegreek.bronze.sales_transactions",
      "SELECT * FROM nikkthegreek.bronze.sales_transactions LIMIT 10",
      "SELECT COUNT(*) FROM nikkthegreek.bronze.sales_transactions"
    ],
    "Plan2": [
      "SELECT * FROM nikkthegreek.bronze.sales_transactions",
      "SELECT * FROM nikkthegreek.bronze.sales_transactions LIMIT 10",
      "SELECT COUNT(*) FROM nikkthegreek.bronze.sales_transactions"
    ]
  },
  "EXPERIMENTS": {
    "Experiment1": {
      "CONNECTION": "Connection1",
      "PLAN": "Plan1",
      "SEQUENTIAL_RUNS_PER_QUERY": 3,
      "PARALLEL_RUNS": 5
    },
    "Experiment2": {
      "CONNECTION": "Connection2",
      "PLAN": "Plan2",
      "SEQUENTIAL_RUNS_PER_QUERY": 2,
      "PARALLEL_RUNS": 4
    }
  }
}

▶️ Running the Benchmark

Use the new structured runner for custom experiments. See also samples.

# Import runner
from perf import runner

# Load configuration from conf.json
import json

with open('conf.json', 'r') as f:
    conf_json = json.load(f)

# Load configuration from conf.yaml
import yaml

with open('conf.yaml', 'r') as f:
    conf_yaml = yaml.safe_load(f)

# Load configuration from conf.py
import conf
conf_py = conf.CONFIG

# Execute runner with experiment name from conf, it returns results as dict
runner.run_experiment("Experiment2", conf=conf_py)

✅ Use Cases

  • Performance benchmarking between Databricks and Synapse
  • Identifying query latency differences

📝 Notes

  • Requires Azure credentials (DefaultAzureCredential) for Synapse authentication
  • Requires Databricks SQL Connector

Improvements

  • Create Warehouse
  • Create APP
  • Command line support
  • pre and post query

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

query_performance_analyzer-0.4.0.dev1-py312-none-any.whl (22.4 kB view details)

Uploaded Python 3.12

File details

Details for the file query_performance_analyzer-0.4.0.dev1-py312-none-any.whl.

File metadata

File hashes

Hashes for query_performance_analyzer-0.4.0.dev1-py312-none-any.whl
Algorithm Hash digest
SHA256 84dac73e1414e9fc2a35d40377842bbf333c9b039da08b16eb5f8cc9d243687e
MD5 f935109d68a8a9fa71d8ce9b5cef01a3
BLAKE2b-256 5385d57d3785f78ae3bc1b0ea58a114a7bbc887d71591c34e3ccbf4198cf507c

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