The story of a system coming to us with a "we've gotten slow" complaint is always similar: the data has grown, queries that used to return in milliseconds have started taking seconds, and the first proposal is always the same: "let's get a bigger server." Yet in our 16 years of experience, in the vast majority of cases the fix isn't hardware but a few well-designed indexes. In this post, we walk through how we diagnose slow queries, the field rules of index design, and the situations where an index is not the answer, using real examples.
Find the culprit first: the slow query log and EXPLAIN
Adding indexes by guesswork is throwing darts in the dark. The first step is to turn on the slow query log (set long_query_time to 1 second, or even 0.5) and collect a week of data. Then examine the most frequent and slowest queries with EXPLAIN. We look at three things: if we see ALL in the type column, there's a full table scan; the rows column shows the number of rows scanned; and "Using filesort" and "Using temporary" in the Extra column point to expensive intermediate operations.

Field rules of index design
- In a composite index, order is everything: for a WHERE durum = ? AND tarih > ? query (status and date columns), an index on (durum, tarih) works; (tarih, durum) won't deliver the same performance. Equality columns first, range columns after.
- The leftmost prefix rule: an (a, b, c) index serves queries on a and on a+b; it doesn't serve b on its own.
- A covering index is worth its weight in gold: if every column the query needs is in the index, MySQL never touches the table at all; that's what seeing "Using index" in Extra means.
- A column wrapped in a function can't use an index: instead of WHERE DATE(olusturma) = '2026-08-18', write a range query; or use MySQL 8's functional indexes.
- Every index has a write cost: every index is updated on each INSERT/UPDATE. Finding unused indexes (sys.schema_unused_indexes) and dropping them is optimization too.

When an index can't save you
Let's be honest: an index isn't the cure for every ailment. If you're paginating with OFFSET 500000, the problem is the query pattern; you need to move to keyset pagination. An ORM usage pattern that produces N+1 queries fires thousands of queries that are fast individually but deadly in aggregate; the fix is eager loading. If reporting queries are locking the live table, summary tables or reading from a replica come into the picture. Every fix written without a correct diagnosis is new technical debt.
Indexes are alive: a maintenance routine
Index work isn't a one-off project; it's a periodic maintenance item. As data distribution changes, a plan that worked perfectly yesterday can go haywire today; when optimizer statistics go stale, you need to refresh them with ANALYZE TABLE. Here's the routine we set up for our clients: the slow query log stays on permanently and a weekly summary report arrives automatically; an unused index scan is run once a quarter; and for every new query pattern added to the schema, EXPLAIN output is required at the PR stage. That way, the "the database got slow" crisis never arises, because the slowdown is caught while it's still a trend. One more version note: MySQL 8's invisible index feature lets you make an index "invisible" before dropping it and safely measure the impact; it's the least risky way to drop an index in production.
A concrete example
Last year, on a vehicle tracking project, a location query was taking 12 seconds; the table had 200 million rows. With an (arac_id, zaman) composite index (vehicle ID and timestamp) and narrowing the query to a date range, the time dropped to 40 milliseconds. The hardware stayed the same. If you have similar suspects in your database, reach out to us; at Rich Design, we carry out query analysis, index design, and database health checks without stopping production.