ShopX

Menu

24/7 Support
Back to Blog
OpenCart module development
MariaDB EXPLAIN for a slow OpenCart catalogue

MariaDB EXPLAIN for a slow OpenCart catalogue

Start with one slow category and a reproducible combination of filters. Measure total server time and time spent in SQL. A PHP profiler or staging query trace can show whether one statement dominates or whether the page repeats many small statements. Grab the real statement shape using representative non-sensitive values before considering a schema change.

Practical check. Record the SQL shape, filter values, query count and response time before each trial. Change one factor and rerun the same workload.

Find the expensive part of the request

Read type, key, rows and Extra for each step in EXPLAIN. The optimizer estimates the number of rows it needs to examine. An ALL access type for a small lookup table can be appropriate. A full scan over a large relationship table is worth investigating in the context of the join order and selected predicates.

CheckWhat it showsWhere to verify
typeAccess methodCheck expensive scans in large tables
keyIndex selectedCompare its leading columns with the predicates
rowsOptimizer row estimateCompare with measured results on staging
ExtraAdditional processingExamine sorting and temporary work in context

Compare plans before and after one change

Composite indexes should fit the filters, joins and sorting used by actual requests. Compare the candidate with existing indexes and verify that the joined columns have compatible types. A new index can help the storefront and slow down writes or imports, so measure both. Benchmark with comparable values, stable sorting and a consistent cache state.

MariaDB's ANALYZE SELECT runs the query and returns actual execution statistics. Use it for a heavy query on a representative test copy. For an N+1 pattern, count queries per page and evaluate grouping the repeated lookup into a batch. Query count and end-to-end latency will show an improvement that an individual EXPLAIN plan may miss.

Frequently asked questions

Is Using filesort automatically a problem?

It marks an extra sort. Check the number of rows and measured cost before changing the index.

Can EXPLAIN uncover N+1 by itself?

Use a per-request query trace to find repeated statements with different IDs. EXPLAIN describes each statement separately.

What do I measure after adding an index?

Check catalogue latency, import throughput and storage costs against the same representative data set.

Share:
← Previous
crm prom: a practical guide to connecting and processing orders

Related Posts

Instant deliveryFiles immediately after payment
Regular updatesLatest module versions
Secure paymentProtected purchase
Technical supportWe will help with the setup