benchmarkSqlGeneric
benchmarkSqlGeneric[ExoBench server version: 1.4.27]
Benchmark a raw SQL query across increasing dataset sizes in an ephemeral SQLite database.
SQLite ONLY. For Postgres/SQL Server/MySQL use benchmarkSql instead (far faster; generates data inside the database). Call getMcpDocs('benchmark-sql-generic') first for full guidance and examples.
WHEN TO USE: to see how a SQLite query's plan and timing change as row counts grow. Prefer EXPLAIN QUERY PLAN queries for plan analysis; use plain SELECT only to sanity-check correctness.
EPHEMERAL: each call builds a fresh database from schema and destroys it on return — nothing
persists. Pass the FULL schema (CREATE TABLE + indexes; NO INSERTs — data is auto-generated) in
EVERY call. correlationId is tracking only; it does NOT preserve DB state.
KEY INPUTS:
query: SQL to benchmark (typically EXPLAIN QUERY PLAN SELECT ...)
schema: CREATE TABLE statements only; declare FKs with REFERENCES so generated data is valid
numRowsToCreate: row counts per iteration, e.g. [100, 1000, 10000]
Optional: perTableRowsOverride (per-table counts), randomSeedOverride (reproducible data), columnConstraints (control generated values), warmCache
OUTPUT: JSON array, one object per iteration, each with sql, output (2D array, headers first),
runtimeDurationMs, and rowsAreCapped. Output is capped at 30 rows but the full result set is
always traversed for accurate timing. On error: {"error": ..., "sql": ...}.
LIMITS: max 5 scale points per request; max 3,000,000 rows per scale point (sum of all tables); Requests exceeding limits are rejected.
IF THIS TIMES OUT: you receive a workerId and a "still running" status — that is NOT a result. Call
benchmarkSqlGenericResults(workerId) repeatedly until it returns a terminal result. Do NOT end your
turn or report findings while a worker is still running. A timed-out response's data field MAY
carry best-effort partial results — do not depend on their presence.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"query": "<query>",
"schema": "<schema>",
"numRowsToCreate": "<numRowsToCreate>"
},
"name": "benchmarkSqlGeneric"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | SQL query to benchmark across different dataset sizes (SQLite only). RECOMMENDED: Use EXPLAIN QUERY PLAN to analyze query execution strategy: EXPLAIN QUERY PLAN SELECT * FROM users WHERE age > 25 This shows how SQLite will execute the query, giving true performance insights. IMPORTANT: When using EXPLAIN, runtimeDurationMs measures the time to run the EXPLAIN query itself, NOT the performance of the analyzed query. It's a dumb timer - it times whatever query you execute. ALTERNATIVE: Use regular SELECT, UPDATE, DELETE, etc. for actual execution: SELECT * FROM users WHERE age > 25 Note: Results are capped at 30 rows. The runtimeDurationMs will only reflect the time to fetch those 30 rows, not the full query execution time. This is why EXPLAIN is preferred for benchmarking. The query runs multiple times with progressively larger datasets as specified in numRowsToCreate. | |
| schema | Yes | SQL schema with CREATE TABLE statements to define SQLite database structure. IMPORTANT: Do NOT include INSERT statements. Data is automatically generated. Must include: 1. CREATE TABLE statements for all tables referenced in the query 2. Column definitions with appropriate SQLite types 3. (Optional) Indexes, foreign keys, constraints Example: CREATE TABLE users ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, email TEXT, age INTEGER, created_at TIMESTAMP ); CREATE TABLE orders ( id INTEGER PRIMARY KEY, user_id INTEGER, total REAL, status TEXT, FOREIGN KEY (user_id) REFERENCES users(id) ); CREATE INDEX idx_user_email ON users(email); CREATE INDEX idx_order_status ON orders(status); Data generation: - All columns are populated with random data based on their type - String columns: Random alphanumeric strings (max 50 chars) - Integer columns: Random integers - Real columns: Random decimals - Date/Time columns: Random dates between 1970-2025 - Boolean columns: Random true/false Note: Foreign key relationships ARE maintained in generated data. The tool uses REFERENCES clauses to detect parent-child relationships and generates valid FK values that reference existing parent rows. Always declare foreign keys explicitly in your schema for accurate data generation or use columnConstraints to make sure the generated data has the right shape. | |
| warmCache | No | How many cache-warming iterations to run before the timed benchmark execution. - false or 0 (default): No cache warming. Query runs against cold shared_buffers. This measures first-query performance as seen by the database. - true: Run the query 5 times before the timed execution to populate shared_buffers. This measures warm-cache performance as seen by repeated queries. - Integer (1-50): Exact number of warm-up iterations. For most queries on datasets up to 3M rows, 3-5 iterations is sufficient to fully warm the page cache. Cache warming affects only the per-query runtimeDurationMs measurement. The total computeSeconds (which includes schema creation, data generation, warming, and teardown) will increase with more warm-up iterations. Note: Warm-up iterations may add significant time for complex queries at high row scales. The polling mechanism (benchmarkSqlResults / benchmarkSqlGenericResults) handles this transparently — if warming + execution exceeds the per-call wait, you'll receive a workerId to poll for results. | |
| databaseType | No | Database type for benchmarking. This tool ONLY supports SQLITE — all other values are rejected. For Postgres/SQL Server/MySQL benchmarking, use benchmarkSql instead — it's 100x faster because it generates test data directly inside the database. Do NOT pass POSTGRES, POSTGRES_18, SQLSERVER, or MYSQL here. | |
| correlationId | No | [TRACKING ONLY — does NOT preserve DB state, schema, or settings between calls.] Echo the correlationId from the previous ExoBench response so the ExoBench team can correlate your workflow for analytics. Omitted = a new one is created. Each tool call still provisions a fresh ephemeral DB from its own schema parameter. | |
| customDelimiter | No | LAST RESORT ONLY — Do NOT use this parameter unless all other approaches have failed. ExoBench has a highly robust, dialect-aware SQL script splitter that correctly handles: - Single-quoted string literals (including '' escape sequences) - Double-quoted identifiers (PostgreSQL, SQL Server) - Bracket-quoted identifiers (SQL Server: [col;name]) - Backtick-quoted identifiers (MySQL: `col;name`) - Dollar-quoted function bodies (PostgreSQL: $$ ... $$ and $tag$ ... $tag$) - Line comments (-- comment; still in comment) - Block comments (/* nested /* block */ comments */ supported for all dialects except MySQL) - MySQL hash comments (# comment; to end of line) - MySQL's -- comment rule (requires whitespace after the dashes) In the vast majority of cases, you do NOT need this parameter. The splitter handles all standard SQL constructs including stored procedures, triggers, and functions that contain semicolons within their bodies. If you encounter a GENUINE splitting failure (the schema executes incorrectly because a semicolon inside a construct was misinterpreted as a delimiter), you may set customDelimiter to a unique string that does NOT appear inside any of your SQL statements. The system will then split ONLY on that string — with NO intelligence about quoting or comments. You are fully responsible for ensuring the delimiter is truly unique in your script. Example: If your schema has a pathological construct that confuses the splitter, you could separate statements with '---SPLIT---' and set customDelimiter to '---SPLIT---'. DO NOT use this to work around issues that the splitter already handles. If you think the splitter is failing on a standard construct, it is almost certainly a bug — report it instead of using this escape hatch. | |
| numRowsToCreate | Yes | List of row counts to benchmark. Each value triggers one benchmark iteration with all tables populated to that row count (unless overridden by perTableRowsOverride). Examples: - [100, 1000, 10000] - Three iterations with 100, 1K, and 10K rows - [1000, 10000, 100000, 1000000] - Four iterations scaling from 1K to 1M rows - [50, 100, 200] - Three iterations doubling each time Best practices: - Start small to verify query works (e.g., 100 rows) - Scale gradually to see where performance degrades - Use powers of 10 for clear scaling patterns: [100, 1000, 10000] - Avoid very large values (>1M) unless necessary - can timeout or exhaust memory The benchmark runs in order and stops if any iteration fails. | |
| columnConstraints | No | Optional list of column constraints to control generated test data values for specific columns. Each constraint specifies a table, column, and allowed values or ranges. Use this parameter to: 1. Model domain-specific constraints that aren't expressed in SQL types (e.g., boolean-as-int, enum values, status codes) 2. Simulate foreign key relationships that exist logically but aren't declared in the schema 3. Generate realistic test data that matches your application's data model Constraint types: **Range constraint** - For numeric columns that should contain values within a specific range: { "type": "range", "tableName": "orders", "columnName": "amount", "from": 100, "to": 500 } Use cases: - Foreign key simulation: Reference IDs from another table (e.g., user_id from 1 to 1000) - Bounded numeric values: Age, percentage, quantity within realistic limits - Date ranges: Year values like 2020-2025 **Values constraint** - For columns that should contain specific literal values: CRITICAL: The isQuoted field is REQUIRED for values constraints. Omitting it defaults to false (no quotes), which causes SQL errors for TEXT columns because unquoted strings are interpreted as column names, not values. WRONG: {"type": "values", "values": ["premium"], "tableName": "customers", "columnName": "tier"} → Generates: tier = premium (SQL error: column "premium" does not exist) RIGHT: {"type": "values", "values": ["premium"], "tableName": "customers", "columnName": "tier", "isQuoted": true} → Generates: tier = 'premium' (correct) Examples for TEXT/VARCHAR columns (strings): { "type": "values", "tableName": "orders", "columnName": "status", "values": ["pending", "shipped", "delivered"], "isQuoted": true } Examples for INTEGER columns (boolean-as-int pattern): { "type": "values", "tableName": "users", "columnName": "is_active", "values": ["0", "1"], "isQuoted": false } Quick reference table: | Column Type | isQuoted | Example values | |-------------------|----------|-----------------------------------| | TEXT/VARCHAR | true | ["pending", "shipped"] | | INTEGER | false | ["0", "1", "100"] | | DATE (literal) | true | ["2024-01-01"] | | NUMERIC/DECIMAL | false | ["99.99", "0"] | Fields: - isQuoted (REQUIRED): true for string/date values that need SQL quotes ('pending'), false for numeric values (0, 1) Use cases: - Enum-like columns: Status codes, tier levels, categories (use isQuoted=true) - Boolean-as-integer: is_active, is_deleted (use isQuoted=false) - PostgreSQL enums: Match enum values defined in schema (use isQuoted=true) - Date literals: Specific dates like '2023-01-01', '2023-06-15' (use isQuoted=true) **Foreign key simulation**: When a column logically references another table's ID but lacks a declared FK constraint: { "type": "range", "tableName": "orders", "columnName": "customer_id", "from": 1, "to": 1000 } This ensures customer_id values (1-1000) align with customer IDs you know exist in the customers table. **Common patterns**: Boolean as integer (0/1): {"type": "values", "tableName": "users", "columnName": "is_active", "values": ["0", "1"], "isQuoted": false} Status enum: {"type": "values", "tableName": "orders", "columnName": "status", "values": ["pending", "processing", "shipped", "delivered"], "isQuoted": true} Tier/category enum: {"type": "values", "tableName": "customers", "columnName": "tier", "values": ["regular", "gold", "platinum"], "isQuoted": true} Simulated FK (not declared in schema): {"type": "range", "tableName": "order_items", "columnName": "product_id", "from": 1, "to": 500} Limited numeric range: {"type": "range", "tableName": "products", "columnName": "rating", "from": 1, "to": 5} Example JSON array with multiple constraints: [ {"type": "range", "tableName": "orders", "columnName": "customer_id", "from": 1, "to": 1000}, {"type": "values", "tableName": "orders", "columnName": "status", "values": ["pending", "shipped", "delivered"], "isQuoted": true}, {"type": "values", "tableName": "users", "columnName": "is_active", "values": ["0", "1"], "isQuoted": false} ] Notes: - Constraints are applied during data generation, ensuring every generated row respects the constraints - Without constraints, columns get random values based on their SQL type - Use range constraints for FK simulation when the FK isn't declared or has data integrity issues - Always set isQuoted=false for numeric types, true for text/date types | |
| randomSeedOverride | No | Optional fixed random seed for reproducible test data generation. If specified, the same seed always generates identical random data across runs, otherwise a default random-seed is used that is also fixed. This ensures fair comparison when benchmarking different queries against the same dataset. Example use cases: - Compare two different query strategies on identical data - Verify optimization changes improve performance consistently - Debug unexpected performance variations If omitted, a default seed is used, still providing reproducibility within a session but potentially varying across different sessions or server restarts. Example: 42 (or any long integer) | |
| perTableRowsOverride | No | Optional map to override row counts for specific tables. Allows fine-grained control over dataset composition for realistic benchmarking scenarios. Format: Map of table name to list of row counts (must match length of numRowsToCreate) CRITICAL: Always use perTableRowsOverride to model realistic data distributions. Real databases have widely varying table sizes based on their domain role: - Lookup/reference tables (categories, tags, statuses): 10-100 rows, constant across scales - Entity tables (users, products, warehouses): 100-10,000 rows, grow slowly - Transaction tables (orders, sessions, events): Primary scaling dimension - Line-item tables (order_items, cart_items): 2-5x transaction count - Junction/mapping tables (product_tags, user_roles): Varies by relationship cardinality - Audit/history tables (returns, refunds, logs): 5-20% of parent table Example for e-commerce at scale [10K, 50K, 100K orders]: { "categories": [30, 30, 30], // Lookup: constant "products": [2000, 2000, 2000], // Entity: slow growth "customers": [2000, 10000, 20000], // Entity: ~20% of orders "orders": [10000, 50000, 100000], // Transaction: primary scale "order_items": [25000, 125000, 250000], // Line-item: 2.5x orders "returns": [1000, 5000, 10000] // Audit: 10% of orders } Without realistic ratios, benchmark results will be misleading. A 1M-row categories table joined to 1M orders produces completely different query plans than the real 30-row categories table would. This creates realistic ratios: - Iteration 1: 30 categories, 2K products, 2K customers, 10K orders, 25K order_items - Iteration 2: 30 categories, 2K products, 10K customers, 50K orders, 125K order_items - Iteration 3: 30 categories, 2K products, 20K customers, 100K orders, 250K order_items IMPORTANT FOR FK RELATIONSHIPS: - Child tables with FKs will have their FK values distributed across available parent rows - Example: 10,000 orders referencing 1,000 customers = ~10 orders per customer on average - If child rows >> parent rows, multiple children reference the same parent (realistic) - If child rows << parent rows, some parents have no children (also realistic) Use cases: - Model real-world data distributions (e.g., each user has ~10 orders) - Test performance with unbalanced tables (e.g., 1M users, 100 categories) - Focus scaling on specific tables while keeping others constant Tables not specified in the map use the corresponding value from numRowsToCreate. | |
| exobenchServerVersion | No | ExoBench server version — copy the X.X.X from the [ExoBench server version: X.X.X] tag at the top of this tool's description. |