Tune MySQL ‘Join’ Buffers for Better Query Performance

mysql tuning of join buffers for improved performance

In MySQL 8.0.20 and later, join_buffer_size sizes the hash join buffer. It is not a dial you turn for a smooth percentage gain — on the workload measured below it did nothing until the buffer was large enough for the hash table to stop spilling to disk, then it stopped mattering again. Find your own … Read more

How to Create Temporary Tables in MySQL with Examples

mysql temporary table uses and examples

Create a `TEMPORARY` table with CREATE TEMPORARY TABLE name (…) — it’s visible only in the session that created it, disappears when that session ends, and can share a name with a permanent table without an error (it shadows it, which is the part most guides skip). Below is real output from MySQL 8.4.10 for … Read more

MySQL Read-Heavy Workloads: Where to Actually Look

optimize mysql for read heavy workloads

This page’s old content no longer has independent territory to own. Its “Case Study” attributed unsourced optimization practices to Amazon and eBay by name; that’s deleted below. Everything else it taught — buffer pool sizing, indexing, read replicas, query caching, monitoring — has since been rewritten elsewhere on this site with real commands run against … Read more

How to Find and Prevent MySQL Deadlocks Easily

how to find mysql deadlocks, prevent deadlocks, and fix deadlocks

Short answer: a MySQL deadlock is two transactions each holding a row lock the other one needs next — InnoDB’s deadlock detector picks one, kills it with error 1213, and the other proceeds. Below is a real one, caused on purpose on a live MySQL 8.4.10 server: two connections locking the same two rows in … Read more

MySQL in Docker: Root Password Off the Command Line

mysql best practices and tips running on docker

Honesty first: this machine has no Docker installed, and none was installed to research this page. Every claim below about Docker or the official mysql image is a direct quote from Docker’s documentation or the image’s Docker Hub page, marked CITED. Every claim about MySQL server settings was actually checked against a live MySQL 8.4.10 … Read more

MySQL Incremental Backups with Custom Scripts: The Binlog Position

mysql incremental backups examples and how to guide

The script this page used to publish was not an incremental backup. It ran mysqldump –all-databases into a dated directory — a full dump, every night, with the word “incremental” over it. And the restore procedure it gave silently does not restore. Both were reproduced below on MySQL 8.4.10. An incremental backup in MySQL is … Read more

How to Secure MySQL: Setting Up SSL/TLS

mysql temporary table uses and examples

An earlier version of this page had a “TLS version vs. key length” table claiming TLS 1.0/1.1 use 128-bit keys and TLS 1.2/1.3 use 256-bit keys. That’s wrong: the TLS protocol version, the cipher suite, and the key size are three separate choices, not one. TLS 1.2 supports ciphers from 128-bit RC4 up through 256-bit … Read more

MySQL Scaling: What Is Actually Left to Decide

mysql performance guide horizontal vs vertical scaling

Short answer: “vertical vs. horizontal” for MySQL isn’t really one decision — it’s three separate ones this corpus already answers individually. Sizing a bigger box is answered, measured, in the buffer pool guide. Read scaling via replicas is answered, with a real replication setup and a measured lag number, in the MySQL scale-out page. What’s … Read more

InnoDB vs. MyISAM: MySQL Performance Compared

mysql temporary table uses and examples

Use InnoDB unless you have a specific, tested reason not to — it’s the default engine in MySQL 8.4, it’s the only one of the two with transactions, row-level locking, foreign keys, and crash recovery, and since MySQL 5.6 it also does full-text search, which used to be MyISAM’s one exclusive feature. The sections below … Read more

MySQL Query Optimization Strategies To Improve Performance

mysql tuning of join buffers for improved performance

Short answer: an index doesn’t make a query faster in the abstract — it changes the plan MySQL chooses, and EXPLAIN ANALYZE proves it. On a 500,000-row table, filtering on an unindexed column costs 50000 and takes ~100ms; the same filter after an index costs 875 and takes ~3ms. Below is that comparison unedited, plus … Read more

Monitoring MySQL 8.4 Without Installing Anything

how to find mysql deadlocks, prevent deadlocks, and fix deadlocks

Short answer: MySQL 8.4 already ships the monitoring most people install a tool for. performance_schema and the sys schema are on by default and answer “what’s slow” and “what’s using memory” without installing anything. What follows is real output from this machine’s server — a listicle of vendor tools isn’t, and the old version of … Read more

MySQL Scale-Out: A Real Replication Setup, Tested

mysql performance guide horizontal vs vertical scaling

Short answer: “performance tuning” (buffer pool sizing, query indexing) is scaling up — a bigger, better-tuned single server. This page is about scaling out: adding replicas so more than one server can serve reads. Below is a real source-to-replica setup, GTID-based, with data actually flowing across it and a measured lag — not the two … Read more

Use Prepared Statements to Boost PostgreSQL Performance

boot postgresql performance with caching

PREPARE saves PostgreSQL from re-parsing and re-planning a query on every execution — but past the fifth call it may silently swap in a generic, parameter-unaware plan instead of continuing to plan around your actual values, controlled by plan_cache_mode. That switch is the real performance story here, and it’s demonstrated below with unedited EXPLAIN output … Read more

PostgreSQL Materialized Views: Refresh, Locking, and CONCURRENTLY

optimize mysql for read heavy workloads

A materialized view stores the result of a query on disk. You query it like a table, and it stays stale until you run REFRESH MATERIALIZED VIEW: CREATE MATERIALIZED VIEW daily_sales AS SELECT date_trunc(‘day’, created_at) AS day, count(*) AS orders, sum(amount) AS revenue FROM orders GROUP BY 1; REFRESH MATERIALIZED VIEW daily_sales; Two things decide … Read more

MySQL Buffer Pool Performance Tuning Guide

mysql tuning of join buffers for improved performance

Short answer: MySQL’s own manual gives one sizing rule, not four: “On a dedicated database server, you might set the buffer pool size to 80% of the machine’s physical memory size.” If the server was started with –innodb-dedicated-server, you don’t even set it — MySQL calculates it for you. Everything below is either a command … Read more

LVM Snapshots Are Not Version Control

lvm linux

An LVM snapshot is not a backup, and calling it “version control” is the part of this page most likely to cost you data. A classic (non-thin) LVM snapshot lives in the same volume group as the volume it snapshots, shares its fate if that volume group’s storage fails, and — this is the part … Read more

PostgreSQL CTEs: Inlined vs MATERIALIZED

postgresql common table expressions (CTE) examples and guide

Since PostgreSQL 12, a plain WITH CTE is inlined into the surrounding query by default — the planner treats it the same as an equivalent subquery, filters can push down into it, and it produces an identical plan. Before 12, a CTE was always an optimization fence: computed once, in isolation, before the outer query … Read more

How to Use Rsync for Backups and File Syncing in Linux

backup files using rsync on linux

For a nightly incremental backup, use this: rsync -a –delete –link-dest=/backup/previous /source/directory/ /backup/2026-08-09/ Correction, and please read this first. An earlier version of this page recommended rsync -av –ignore-existing /source/directory/ /backup/directory/ and described –ignore-existing as transferring “only new or modified ones”. That is wrong in the direction that destroys backups: modified files are never transferred. … Read more

NFS vs. Samba: Linux File Sharing Explained

learn about linux file sharing using NFS and SAMBA

Do not copy the export line or the share block the earlier version of this page gave you. It printed sudo exportfs -o rw,sync,no_root_squash *(directory_path) as a “case study” command, exported /home to every host on the network with /home *(rw,async,no_subtree_check), and published a Samba share containing guest ok = yes alongside writable = yes. … Read more

Sharding vs Partitioning: A Guide to PostgreSQL Scalability

postgresql data partitioning and sharding

Short answer: partitioning splits one big table into smaller pieces on one PostgreSQL server; sharding splits data across multiple servers. Partitioning is native — CREATE TABLE … PARTITION BY ships in core PostgreSQL. Sharding is not: core PostgreSQL has no built-in sharding, full stop. Getting there means an extension (Citus, not installed here) or building … Read more