MySQL database optimization for PHP apps that got slow
This page is for teams whose PHP app gets slower as the tables grow. I find the slow MySQL queries in your app. I fix each one at the source. I scope each job separately before I quote a price.
Is it the database or something else?
The database is a likely cause when you see these signs:
- Pages that were fast at launch now take seconds to load.
- Reports or exports time out when the date range grows.
- The database server runs at high CPU during normal traffic.
- A planned feature is difficult because of how the tables are laid out.
The cause is probably something else in these cases:
- The slow part is the front end, such as large images or heavy scripts.
- You need a database administrator on call at all hours. I do not offer that service.
What I need from you
Before I start, I need access to three things:
- the server
- the database
- the source code
Client work can stay private under an NDA. I do not share client names.
What I fix
Slow queries
Each fix targets a query from your own logs. You can see which page got faster and why.
Indexes
I build indexes for your real WHERE and JOIN clauses. I do not add extra indexes that slow down every write.
Table structure
I change the schema and write migrations that fit the features you plan.
Code logic
In Laravel, I fix Eloquent code that loads too much, such as missing eager loading. In plain PHP apps, I tune the raw SQL. A loop that sends one query per row is a common cause.
WordPress and WooCommerce
I also tune WordPress and WooCommerce databases, such as WooCommerce stores with slow product queries.
One example
One app had slow queries because the SQL used too many joins. I changed the table structure. I also changed the logic in the code that sent those queries. After these two changes, the app ran faster.
Databases and tools I use
I work with MySQL, MariaDB, PostgreSQL and Redis. To find slow queries, I use the slow query log and EXPLAIN. In PHP code, I work with Eloquent and Doctrine. I have designed MySQL databases since 2013. At SEREWare, I built PHP and MySQL web applications and their databases.
How the tuning runs
Measure
I turn on the slow query log and collect a baseline from real traffic.
Diagnose
I run EXPLAIN on the worst queries and trace them back to the PHP code.
Fix on a copy
I test indexes, query rewrites and schema changes on a copy of your data. I do not change the live database first.
Roll out
I apply the changes with a backup and a rollback path. Then I compare the result with the baseline.
What you get at the end
You get a short report. It tells you what was slow, what changed, and which queries to watch. Keep the slow query log on, so new problems show early. I can check again later if you want.
MySQL optimization FAQ
01How much does MySQL database optimization cost?+
02Do we need a new database, or can you fix the one we have?+
03Will the site go down while you change the database?+
04Is the fix in Laravel Eloquent or in raw SQL?+
Pages getting slower every month?
Send me the slow pages or your slow query log. I will tell you where the time goes and what I would fix first. You decide before you commit to anything.
Data behind an API? See PHP API development. Running PostgreSQL, or tuning the API in front of the database? See database optimization.


