# Performance optimisation — Stage 1 baseline

Measured on 2026-08-15 against the local Laravel HTTP kernel with `APP_ENV=production`, MySQL, and the configured `http://localhost:8000` application URL. Each route was requested once sequentially. The profiler records application response time, database query count and duration, duplicate SQL fingerprints, response bytes, and PHP memory delta. These are local application measurements, not browser/network Core Web Vitals.

## Before changes

| Route | HTTP | Response (ms) | Queries | DB (ms) | Repeated executions |
| --- | ---: | ---: | ---: | ---: | ---: |
| Homepage | 200 | 433.60 | 38 | 268.98 | 32 |
| Category listing | 200 | 1082.43 | 41 | 504.10 | 28 |
| Product details | 200 | 319.17 | 20 | 237.84 | 12 |
| Shop listing | 200 | 500.75 | 37 | 247.50 | 26 |
| Search | 200 | 808.51 | 15 | 763.36 | 2 |
| Cart | 200 | 561.19 | 9 | 432.90 | 4 |
| Checkout | 302 | 278.81 | 5 | 197.43 | 0 |
| Customer dashboard | 302 | 12.83 | 3 | 4.10 | 0 |
| Admin dashboard | 200 | 1035.38 | 20 | 892.06 | 5 |
| Admin product listing | 200 | 388.74 | 16 | 50.63 | 7 |
| Admin order listing | 200 | 196.79 | 5 | 3.80 | 0 |

## After changes

| Route | HTTP | Response (ms) | Queries | DB (ms) | Repeated executions |
| --- | ---: | ---: | ---: | ---: | ---: |
| Homepage | 200 | 209.65 | 8 | 33.64 | 2 |
| Category listing | 200 | 109.83 | 15 | 47.76 | 4 |
| Product details | 200 | 102.09 | 20 | 35.97 | 6 |
| Shop listing | 200 | 103.12 | 15 | 29.07 | 2 |
| Search | 200 | 75.26 | 15 | 29.83 | 2 |
| Cart | 200 | 47.83 | 9 | 13.71 | 4 |
| Checkout | 302 | 17.26 | 5 | 5.40 | 0 |
| Customer dashboard | 302 | 32.70 | 3 | 20.07 | 0 |
| Admin dashboard | 200 | 80.02 | 13 | 23.08 | 2 |
| Admin product listing | 200 | 186.48 | 10 | 106.74 | 0 |
| Admin order listing | 200 | 34.49 | 5 | 9.70 | 0 |

## Scope and caveats

- The database contains no customer user, cart, or order fixture suitable for an authenticated checkout/customer-order journey. Checkout and customer dashboard therefore correctly redirected (302); no orders or user data were created for profiling.
- A one-request sample is sensitive to local cache and database state. The before/after direction and query reductions are useful, but the absolute milliseconds should be rechecked with representative production data and a load test in Stage 5.
- Laravel Pulse writes telemetry during these requests and is included in the raw query counts. The route-query improvements are therefore conservative.
- The audit found `visitors.ip`, `visitors.user_id`, and product/category slugs stored as text types in the existing database. The migration uses safe MySQL prefix indexes for those text columns.
