MADEBYARIS
MySQL for PHP apps

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

1

Measure

I turn on the slow query log and collect a baseline from real traffic.

2

Diagnose

I run EXPLAIN on the worst queries and trace them back to the PHP code.

3

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.

4

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

How much does MySQL database optimization cost?+

The price depends on the size of the database and the number of slow queries. I scope each job separately. You get a scope and a quote before I change anything.

Do we need a new database, or can you fix the one we have?+

You can keep the one you have in most cases. Most slow MySQL setups need better indexes, rewritten queries or some schema changes. If a move to a different database is necessary, I tell you plainly.

Will the site go down while you change the database?+

Most index and query fixes run while the site stays online. Large table changes can lock writes. I test those on a copy of the data first. I schedule them for a quiet hour, with a backup ready.

Is the fix in Laravel Eloquent or in raw SQL?+

It can be in either place. In my example above, the fix was in both the table structure and the code logic.

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.