4. Choose the right platform for the data
Some performance problems are not tuning problems. They are placement problems: data kept on a platform that is wrong for the way it is used. No index will fix a four-billion-row clickstream table that is scanned for weekly aggregates on the same server that takes customer orders.
This chapter asks three questions. Is the data in the right storage? Does it all need to be relational? And if part of it moves elsewhere, how do you keep the whole data tier cohesive?
4.1The familiar-platform trap
One of the most common sources of long-term performance debt has nothing to do with SQL. Teams extend the platform they already know with data that doesn't fit it.
It happens one reasonable step at a time. An events table lands in the OLTP database because the team knows that engine and the data is "just rows". Application logs go into the main database because the DBA team already backs it up. One relational database slowly becomes a queue, a search engine, a time-series store and a data lake, all at once. A key-value cache quietly turns into the system of record. Each step avoids new skills, new procurement and new runbooks, so each step looks cheap.
Together they build technical debt with interest:
- The platform is tuned for one workload and now fights four. Settings that help OLTP hurt the scans, and the other way around.
- Maintenance windows grow: statistics, vacuum, index rebuilds and backups are all sized by the biggest, least valuable table.
- Restores slow down, so recovery time objectives quietly stop being met.
- Licensing scales with data that uses none of the licensed features. On an engine licensed per core, archive data that is read twice a year can still drive the hardware, and with it the licence bill.
- Workarounds pile up: polling tables used as queues,
LIKE '%term%'searches, triggers that maintain summary tables, generic entity-attribute-value tables, giant JSON blobs. - Every later migration gets harder, because applications now depend on the wrong shape.
How to avoid the trap:
- Make platform choice a design-review question, with explicit criteria: access pattern, volume and growth, consistency needs, retention, and cost per terabyte including people.
- Prototype at realistic volume. A design that works at one million rows can fall over at one billion.
- Decide the data lifecycle at creation: who deletes it, when, and how. A purge job written on day one is cheap; one written in year five is a project.
- Set review triggers, such as a table that grows tenfold or enters the top three by storage, and revisit its placement when one fires.
- Weigh familiarity, don't assume it. Operational skill is a real asset and a valid criterion. It should be one input to the decision, not the whole decision.
4.2Does it all need to be relational?
Relational engines are superb at what they were built for, and stretchable well beyond it. The question is where stretching stops paying.
| Data and workload | Relational fit | Alternatives when it outgrows the fit |
|---|---|---|
| Transactions with integrity rules and concurrent updates | Excellent | Keep it relational |
| Point lookups and short range scans | Excellent | Keep it relational |
| Reporting on recent data with joins | Good | Indexes, read replicas, materialized views |
| Batch processing and bulk loads | Excellent in sets, poor row by row | Set-based or bulk SQL first; an external pipeline only for very large transforms |
| High-volume, append-only events, logs and telemetry | Fair, then poor at scale | Partitioned and compressed tables first; then a columnar store, or Parquet files in object storage |
| Large history scanned for analytics | Poor in row stores | Columnar storage inside the engine, where offered; a columnar warehouse; Parquet or Iceberg tables with a query engine |
| Full-text search | Fair (built-in full-text features) | A dedicated search engine for heavy or relevance-ranked use |
| Documents with highly variable structure | Fair (JSON types) | A document store, if the relational part is small |
| Work queues | Fair (reads that skip locked rows work well at moderate rates) | A message broker for high throughput or fan-out |
| Files and large binary objects | Poor | Object storage, with a reference in the database |
Batch work is the workload most often moved out too early. A nightly job that crawls is usually working one row at a time; rewritten as set-based or bulk SQL, it often fits its window again on the same platform. Every engine has a fast load path and a way to work on rows in sets. The engine notes show both, plus a batch read for a work queue (Chapter 9 shows longer rewrites).
4.3Tier inside the engine first
The cheapest way to split hot and cold data is often to stay in the same engine. You keep one security model, one backup, one set of skills, and frequently that alone fixes the problem.
- Partition by date (Chapter 10) so old data can be compressed, moved or dropped a partition at a time instead of with huge
DELETEstatements. - Compress older partitions. Most engines can compress data that rarely changes, by row, by page or by column. Check which kinds need a paid option.
- Move cold partitions to cheaper storage with tablespaces or filegroups on slower disks.
- Use columnar storage for history, where the engine offers it. On an archive table or on older partitions it can shrink the data several-fold and speed up scans dramatically.
- Use archive tables or an archive database with the same schema, and query across them with a view when needed.
- Send reporting to a read replica to protect the primary from long scans.
4.4Hybrid data tiers: when part of the data leaves
When data truly doesn't belong in the OLTP engine (large, append-mostly, scanned rather than looked up), move it to a tier built for that, and keep it queryable.
Open file formats. Parquet stores data by column, compressed, so analytic scans read only the columns they need. Table formats such as Apache Iceberg (and Delta Lake or Apache Hudi) add what plain files lack: atomic commits, snapshot isolation for readers, schema evolution, partition evolution and time travel.
Foreign and external tables let the database itself read data that lives elsewhere:
| Engine | Options |
|---|---|
| PostgreSQL | Foreign data wrappers: postgres_fdw and file_fdw ship with PostgreSQL; third-party wrappers and extensions read Parquet and object storage |
| MySQL | No general foreign-table feature in the community server. The FEDERATED engine reaches only other MySQL servers and is rarely a good idea for performance. For files in object storage, use a federated engine (below) or a managed service with lakehouse features |
| SQL Server | PolyBase external tables. SQL Server 2022 reads Parquet, CSV and Delta files in S3-compatible object storage and Azure storage (OPENROWSET, CREATE EXTERNAL TABLE) and can write cold data out as Parquet with CREATE EXTERNAL TABLE AS SELECT |
| Oracle | External tables (ORACLE_LOADER, ORACLE_DATAPUMP); hybrid partitioned tables in 19c, with some partitions internal and some external (requires the Partitioning option); newer releases add an access driver for Parquet and other object-storage formats |
Federated SQL engines query many sources in one statement. Trino is the best-known open-source example, with connectors for PostgreSQL, MySQL, SQL Server, Oracle, Iceberg, Delta Lake, Hive and more. Starburst is its commercial distribution, and Amazon Athena's current engine is based on it. Trino turns "the hot data is in the OLTP database and the history is in Parquet" into one logical table.
4.5Keeping a hybrid tier cohesive
A hybrid tier is only an improvement if people can still find, trust and query the data. These practices keep it cohesive.

- One catalog of record. Register lake tables in one catalog (a Hive metastore, AWS Glue or an Iceberg REST catalog) and keep names and keys consistent across tiers:
ordersin the OLTP database,orders_historyin the lake, the same column names and types in both. - One query entry point for analytics. In Trino, each source is a catalog. A view can union the hot and cold parts behind one name, split at a watermark so no row is counted twice:
-- Trino: one logical orders table across two tiers.
-- 'pg' is a PostgreSQL catalog and 'lake' an Iceberg catalog; both names are yours to choose.
CREATE OR REPLACE VIEW lake.analytics.orders_all AS
SELECT order_id, customer_id, order_date, total_amount
FROM pg.public.orders
WHERE order_date >= DATE '2026-01-01' -- the watermark: move it when you move data
UNION ALL
SELECT order_id, customer_id, order_date, total_amount
FROM lake.archive.orders_history
WHERE order_date < DATE '2026-01-01';- Move data with a contract. Move whole partitions, verify row counts and checksums, move the watermark, then drop the source partition. Trino can do the copy itself (
INSERT INTO lake.archive.orders_history SELECT ... FROM pg.public.orders WHERE ...), and some engines can write open formats directly (see the table in section 4.4). For continuous feeds, use change data capture (for example Debezium, AWS DMS, SQL Server CDC or Oracle GoldenGate, which is licensed separately). - The same security everywhere. Map roles across tiers, apply the same masking for personal data, and make sure archived copies are covered by the same retention and deletion rules as the source.
- Know what gets pushed down. Trino pushes filters, and for many connectors also projections, aggregations, joins and
LIMIT, down to the source database. What it can't push down, it pulls across the network. Filter early, and readEXPLAINoutput in Trino to see what really runs where. - Define freshness and consistency. There are no transactions across sources. Agree how far behind the lake may be, and make the watermark boundary exclusive on one side and inclusive on the other.
- Observe the federated layer too. Trino keeps query history (
system.runtime.queries) and exposes worker metrics. A slow federated query is often a slow source query in disguise, so trace it back. - Watch the cost model. Object storage is cheap, scanning isn't always (some services charge per terabyte scanned). Partition and sort lake tables by the columns people filter on, and compact small files regularly.
4.6Before you move a table out
Ask these questions, and write the answers down:
- What share of database time, storage and maintenance time does the table account for today, and in a year?
- Would partitioning, compression or archiving inside the engine solve the problem?
- Who queries the data after it moves, how often, and how fast must the answer be?
- What consistency do those readers need?
- Who owns the lifecycle: the move, the verification and the deletion?
- What will it cost to run, people included?
If the table is cheap to keep where it is, keep it there. Hybrid tiers pay off when data is large, cold and scanned; they cost you when data is small, hot or transactional.
This is one chapter of the free database tuning guide for PostgreSQL, MySQL, SQL Server and Oracle. Download the whole guide as a PDF.