In our own vehicle tracking system, a single location table generates hundreds of millions of rows a year; write one location every 30 seconds per vehicle and the math takes you there on its own. Last month we also got this call from a client: "The cleanup script that runs overnight didn't finish by morning, the table stayed locked, and operations stopped first thing." What was the problem? Trying to delete three years of data from a 400 million-row table with DELETE. These two stories are two sides of the same lesson: past a certain scale, the era of "we'll add an index and it'll be fine" is over. There are three mature strategies for living with a big table — partitioning, archiving, and a data lifecycle designed correctly from the start — and in this post I'll walk through all three with examples from the field.
First, the honest question: why is this data still here?
This is the question to ask before jumping to a technical fix. If 99% of your queries ask for the last 3 months of data, keeping 5 years of raw records in the operational table is a penalty everyone pays: queries slow down, indexes no longer fit in memory, backups take hours, and disaster recovery time stretches out.
On every project we classify data into three temperatures. Hot data is the slice daily operations use — in vehicle tracking, the locations from the last few months. Warm data is the period reporting comes back to now and then — last year's comparison reports, for example. Cold data is the part almost nobody reads but that can't be thrown away because its legal retention period hasn't expired. There is no engineering justification for keeping these three tiers in the same store, at the same cost, with the same performance expectations. Once the tiers are separated, the solutions become clear on their own.

Partitioning: one table, many drawers
In MySQL and PostgreSQL, splitting a table by date — in our practice almost always with monthly RANGE partitions — keeps the logical appearance of a single table while physically separating the data into drawers. A query for "the October idling report" no longer scans 400 million rows, only the October drawer; this is called partition pruning, and when it's set up correctly the effect is dramatic.
But partitioning's real superpower shows up in maintenance, not in queries. Remember the client from the opening whose DELETE disaster ran until morning: on a partitioned table, the same job takes seconds with DROP PARTITION. No locks, no undo log bloat, no replication lag. That's the difference between deleting millions of rows one by one and pulling out the whole drawer and tossing it. We moved that client's table to monthly partitions; the cleanup job that used to eat the whole night is now a single line in cron that takes a few seconds.

A quick word on engine differences. PostgreSQL's declarative partitioning has matured significantly in recent versions; on the MySQL side, RANGE partitioning has been running stably for years. But the two engines have different constraints — rules such as unique indexes having to include the partition key will shape your design in places you don't expect. Whichever engine you're on, test the plan against that engine's real constraints, with production-like data; the concepts are shared, the details are not.
I need to write one warning in capital letters: if the partition key doesn't appear in your queries, pruning doesn't kick in and you get no benefit at all from this whole architecture — some queries may even get slower. If you partitioned by date but your reports always filter by customer number, the database still has to open and look inside every drawer. The key is chosen based on your query patterns, not on fashion, a blog post, or the neighbor's project. Before deciding on partitioning, pull your 20 most frequently run queries and look at their WHERE clauses — that list makes the decision.
The gain on the index side belongs in the calculation too: in a partitioned table each drawer has its own index, and the active month's index fits comfortably in memory. A single index over 400 million rows has no chance of living in memory, while an 8 million-row monthly index lives there quite happily; the relief in insert speed is a bonus. On our location tables, write performance improved visibly after the move to partitions.
An archive has to be queryable
Our recipe for the cold tier: move the data to object storage in a compressed columnar format (Parquet is our standard) and delete it from the operational database. The gain comes from two directions — storage cost drops severalfold (compression ratios on repetitive data like location data are genuinely impressive), and because the operational database shrinks, backups, replication and maintenance operations all get faster.
The critical rule is this: the archive should not be a "write it and forget it" place but a queryable tier. When a legal request comes in — and in the vehicle tracking world it does: accident investigations, disputes, audits — you need to be able to open up and present the 2019 records in a reasonable amount of time. Tools that run queries over Parquet files are quite mature today; pulling data from the archive doesn't have to be pleasant, but it has to be possible.
Retention policy also has a legal dimension. For records that qualify as personal data, KVKK (Turkey's personal data protection law) says "don't keep it longer than necessary," while sector-specific regulations require you to keep some data for years. In other words, both "let's keep everything forever" and "let's delete the old stuff right away" can be legally risky. Have your legal counsel at the table when you write the policy; on client projects we put this meeting at the very start of the work, because the technical architecture is shaped by those answers.
And let's mention the trap that catches everyone: the archive job gets written, it runs, it gets forgotten — and one day you discover it's been failing silently for months. Don't let your archive job run unmonitored; put a "how many rows were moved this month" metric on a dashboard.
If you're building from scratch, do it from day one
The cheapest version of everything I've described is the one set up while the table still has 10,000 rows. Our recipe for new projects runs in four steps. First, a retention policy is written: which data, for how long, in which tier — this is as much a legal document as an engineering one, and it's signed off together with the client. Every table with a time-series character (locations, logs, events, measurements) is partitioned monthly on the day it's born; partitioning after the fact is a migration project in its own right, while doing it from the start is nearly free. A monthly automated archive job is set up and hooked into monitoring. And heavy reports run not against the operational database but against a replica or a reporting layer — slowing down operations in the field because management is pulling its Monday morning report is not acceptable.

Once these four are in place, the "the table grew and the system stopped" crisis becomes history for you. When they aren't, the crisis is a matter of scheduling; it's certain to come, only the date is unknown.
Moving an existing giant table to a partitioned structure doesn't require a big bang either: you set up the new partitioned table alongside it, route new records into it, and move the old data in the background in controlled batches. With a migration job that runs during quiet traffic hours, the move is completed in a few weeks without users noticing a thing. Slow but uninterrupted — that's always the direction we prefer.
If you have a giant table that has hit its limits right now, don't panic — as in the client example above, an uninterrupted transition on a live system is possible; it just takes careful planning. Write to us with your table size, query patterns and retention needs, and let's work out together how many drawers you need. Doing that math is always cheaper than putting it off.