Home / Databases / MySQL database optimization

MySQL and MariaDB database optimization: server configuration, slow queries and indexes

We look inside the server and MySQL or MariaDB: memory, global variables, bottleneck queries, indexes and tables that grew too large. You get the diagnosis with numbers, what was tuned and the gain measured before and after.

What's included

  • Analysis of the server and the real database load
  • Review of MySQL or MariaDB global variables
  • Slow query logging and analysis
  • Indexes created and tables cleaned, with a backup first
  • Report with before and after measurements

How we analyse your database

A slow database rarely has a single cause. We look from the server down to the query, in that order, to fix what actually weighs.

1

The server first

Free and used memory, swap usage, disk and I/O wait, CPU, other services competing for resources, and the MySQL or MariaDB version. Without this, any tuning is guesswork.

2

Global variables

We compare the configuration (my.cnf) with the database's own counters (SHOW GLOBAL STATUS) to see where memory is short, where it is wasted and where the default settings do not fit your load.

3

Bottleneck queries

Slow query log enabled during a real period, grouping of the queries that add up to the most time, and an EXPLAIN of each one to see whether it uses an index, creates temporary tables or scans the whole table.

4

Indexes and tables

Missing and duplicate indexes, tables still on MyISAM converted to InnoDB, and tables bloated with sessions, logs, abandoned carts and expired temporary data.

Time of the heaviest queriesBefore After tuning
tuning
Beforeslow queries, full table scans and locks at peak hoursAfterfast, predictable queries, even with more traffic

Illustration of typical behavior. Your query times are measured before and after and included in the report.

Global variables we review

VariableWhat it doesWarning sign
innodb_buffer_pool_sizeMemory where InnoDB keeps data and indexesLots of reads going to disk while the server has spare memory
innodb_redo_log_capacitySize of the transaction log (innodb_log_file_size on older versions)Slow write bursts and constant forced flushes to disk
max_connectionsMaximum simultaneous connections"Too many connections" errors at peak times, or memory running out because the limit is too high
tmp_table_size · max_heap_table_sizeSize of in-memory temporary tablesMany temporary tables created on disk (Created_tmp_disk_tables)
table_open_cache · table_definition_cacheHow many tables stay open in cacheThe Opened_tables counter rising nonstop
thread_cache_sizeConnection reuseHigh Threads_created relative to connections
sort_buffer_size · join_buffer_sizeMemory reserved per queryHigh values copied from generic recipes, which multiply memory use per connection
innodb_flush_log_at_trx_commitBalance between safety and write speedSlow writes; we only change it with your agreement, after explaining the risk

The query cache was removed in MySQL 8. MariaDB still has it, but it tends to hurt write-heavy sites such as stores, and is almost always turned off.

What we usually find on each platform

WordPress

Options loaded on every page (autoload) that grew past several megabytes, expired transient data, custom field searches without an index, and the WooCommerce task queue with millions of rows.

PrestaShop

Connection, visitor, page-not-found and statistics tables growing without limit, years of abandoned carts and an outdated search index.

Magento

Indexers running on every save instead of on a schedule, piled-up log and quote tables, and delayed scheduled tasks competing with the store for the database.

Drupal · Joomla · Moodle

Sessions, event logs and cache stored in the database, log tables nobody cleans and report queries running at peak time.

When the bottleneck is in the code

We show the exact query, which plugin, module or screen it comes from and how much time it adds up to per hour. We propose the index, the code fix or an object cache with Redis, and explain what each option solves.

What you get

A before-and-after report: time of the heaviest queries, disk reads, memory use and slow queries per hour. The previous configuration is kept so it can be restored if needed.

Every database is analysed first: you get the diagnosis, what we propose and the price in writing. All on a quote basis.

Request a database analysis See performance and Cloudflare

How it works

  1. Baseline measurement

    We turn on the slow query log during a period of normal use and record memory, disk reads, connections and site response time.

  2. Diagnosis

    We compare the global variables with what the server has and what the database actually does, and list the queries that take the most time, with an EXPLAIN for each.

  3. Written proposal

    You get what we found, what we propose to change, the risk of each change and the price, before anything is touched.

  4. Changes with a backup

    Backup of the database and configuration before any change, tuning at the quietest time, and a service restart only when needed.

  5. New measurement

    We repeat the measurement under the same conditions and deliver the before-and-after comparison.

Who it's for

Agencies

Many customer sites on a stable server, without needing an infrastructure person.

Online stores

Consistent checkout performance on peak days, with daily backups.

Portals and blogs

Layered caching and Cloudflare to handle traffic spikes.

You don't have to trust us on day one

Being wary is the right call when you hand over access to a server. So we work in a way you can check at every step.

Diagnosis before any charge

You get in writing what we found, what can be done and what it costs. Only then do you decide.

Backup before any change

Nothing is changed without a copy of the current state. If something turns out differently than expected, we roll back.

Your credentials stay yours

We use your passwords only for the job you hired us for. When it is done you can change them all, and we show you how.

Everything explained at the end

You get what was done, why it was done and what we recommend going forward, in plain language.

No lock-in

Cancel any time from the customer area. The service runs until the end of the paid period and you leave with a copy of your data.

Who does the work

Marcio Nunes has worked in IT since he was 16 and has run sites and servers for customers in several countries since 2010, including sites for public bodies and public figures we cannot name. He is the one accountable for your service.

Read the story

Frequently asked questions

Can't find your question? Talk to the team.

Does it work on a server you do not host?

Yes. We analyse and tune MySQL or MariaDB wherever it runs, on a VPS, a dedicated server or your company's own server, as long as there is access to the server or the database.

Does the site go offline during the changes?

The analysis does not affect the site. Some variables only change when MySQL restarts, which takes seconds and is done at the quietest time, agreed with you.

Can a shared hosting database be optimized?

Not the global variables, because the server is shared with other sites. But indexes, queries and oversized tables can be handled, and that is often where the biggest gain is.

How much does it cost?

It depends on the size of the database and how many systems use the server. We work on a quote basis, with the price in writing after the baseline measurement.

Talk to a specialist

We analyze your site or server and send a proposal with scope and timeline. Reply the same business day.

Want to share more detail? Use the full form

We only use your details to reply to this message.