# SQL Query Performance Tuning Log Worksheet

> Source: https://netray.co/tools/sql-query-performance-tuning-log-worksheet
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

An editable log of slow ERP queries with before and after timings that computes percent improvement and CPU hours saved per day.

## Category

developer

## Audience

- ERP analyst
- DBA
- ERP developer

## Tool

**Kind:** worksheet

**Mode:** editable

**Columns:**

#### Query or report

**Key:** query

**Type:** text

#### System

**Key:** system

**Type:** select

**Options:**

- ERP database
- Reporting database
- Data warehouse
- Integration

#### Fix applied

**Key:** fix

**Type:** select

**Options:**

- New index
- Rewrite query
- Statistics update
- Parameter fix
- Archive data
- Other

#### Before (ms)

**Key:** before_ms

**Type:** number

**Unit:** ms

#### After (ms)

**Key:** after_ms

**Type:** number

**Unit:** ms

#### Runs per day

**Key:** runs_day

**Type:** number

#### Improvement

**Key:** gain_pct

**Type:** number

**Expr:** (before_ms - after_ms) / before_ms * 100

**Format:** percent

#### Elapsed hours saved per day

**Key:** hours_saved

**Type:** number

**Expr:** (before_ms - after_ms) * runs_day / 3600000

**Format:** decimal

#### Tested on

**Key:** tested

**Type:** date

**Rows:**

**Query:** Open sales order lines by customer

**System:** ERP database

**Fix:** New index

**Before ms:** 14200

**After ms:** 380

**Runs day:** 900

**Tested:** 2026-10-05

**Query:** Inventory aging summary

**System:** Reporting database

**Fix:** Rewrite query

**Before ms:** 96000

**After ms:** 18500

**Runs day:** 40

**Tested:** 2026-10-07

**Query:** Open purchase orders past due

**System:** ERP database

**Fix:** Statistics update

**Before ms:** 7600

**After ms:** 2100

**Runs day:** 300

**Tested:** 2026-10-08

**Query:** Nightly shipment interface load

**System:** Integration

**Fix:** Parameter fix

**Before ms:** 420000

**After ms:** 95000

**Runs day:** 1

**Tested:** 2026-10-12

**Query:** Work order cost rollup

**System:** ERP database

**Fix:** Archive data

**Before ms:** 61000

**After ms:** 33000

**Runs day:** 24

**Tested:** 2026-10-14

**Totals:**

#### Total elapsed hours saved per day

**Key:** hours_saved

**Agg:** sum

**Format:** decimal

#### Average improvement

**Key:** gain_pct

**Agg:** avg

**Format:** percent

**Summary:**

#### Elapsed hours saved per year (365 days)

**Key:** hours_year

**Expr:** sum_hours_saved * 365

**Format:** number

**Primary:** true

#### Queries tuned

**Key:** tuned

**Expr:** count

**Format:** integer

**Notes:** Record timings under comparable load and with warm and cold cache noted. Elapsed time saved is not the same as CPU time saved when queries run in parallel. For CPU, capture total_worker_time from sys.dm_exec_query_stats before and after.

## Content

**Intro:** Tuning work is easy to lose: nobody remembers which index was added or how much it helped. This worksheet logs each slow ERP query with before and after timings, the fix applied and how often it runs, then totals the improvement and the daily time saved.

**Sections:**

#### How to use it

**Body:** Add one row per query or report you tune. Record the elapsed time before and after under similar load, the number of runs per day, and the fix you applied. The sheet calculates the percent improvement and the elapsed hours saved per day. Use the dropdowns to keep fix categories consistent, then export to Excel to share with the team or attach to a change record. Review the log after upgrades to catch regressions.

**Bullets:**

- Capture a before timing first, always
- Use the same parameters for before and after
- Log the date so regressions can be traced to releases

#### Choosing what to tune

**Body:** Rank candidates by total cost, not by the slowest single run. A query that takes 7 seconds and runs 300 times a day costs more elapsed time than a 90 second report that runs once. Pull candidates from sys.dm_exec_query_stats ordered by total_elapsed_time or total_worker_time, from your ERP's own slow-query logs or from user complaints about a specific screen. Log the highest total cost first.

#### Reading the totals

**Body:** Improvement percent shows the relative gain; elapsed hours saved per day shows the practical value. In the sample, the open sales order query dropped from 14 seconds to under half a second and runs 900 times a day, saving more than three hours of waiting. That is a stronger case than a large percentage on a rare report. The yearly figure helps justify DBA time.

#### Common mistakes

**Body:** Comparing a cold-cache before with a warm-cache after exaggerates the gain. Changing parameters between tests does the same. Another trap is adding an index that speeds one query and slows writes on a busy table, so also note write impact. Keep a rollback script for every change.

**Cta:** If you want help finding the most expensive queries in your ERP database, we can run a read-only analysis on your own servers.

**Faq:**

#### What counts as a good improvement?

**Answer:** It depends on frequency. A 90 percent gain on a query that runs thousands of times a day matters. A 50 percent gain on a monthly report may not be worth the risk. Use the elapsed hours saved per day to decide where effort pays.

#### How do I get reliable before and after timings?

**Answer:** Run each version several times with the same parameters on the same data and take the median. Note whether cache was warm. SET STATISTICS TIME ON or Query Store runtime statistics give consistent numbers on SQL Server.

#### Should I log CPU time as well?

**Answer:** Yes, if parallelism is involved. Elapsed time can fall while CPU time rises. You can add a column in Excel after export, or log total_worker_time from sys.dm_exec_query_stats for each query before and after.

#### Can I use this for non-SQL Server systems?

**Answer:** Yes. The sheet is database-neutral. Record timings from Oracle AWR, PostgreSQL pg_stat_statements, DB2 or your ERP's own tracing. The improvement and time-saved formulas are the same.

## Search terms

sql query tuning log template, slow query tracking spreadsheet, query performance before after worksheet, erp report performance tuning log, sql tuning excel template, cpu hours saved query tuning

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
