<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>MySQL on Zhuifeng Notes</title><link>https://4f0a9a3b.wangpeng.pages.dev/en/tags/mysql/</link><description>Recent content in MySQL on Zhuifeng Notes</description><generator>Hugo</generator><language>en</language><lastBuildDate>Tue, 25 Aug 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://4f0a9a3b.wangpeng.pages.dev/en/tags/mysql/index.xml" rel="self" type="application/rss+xml"/><item><title>MySQL Indexing Internals and Best Practices</title><link>https://4f0a9a3b.wangpeng.pages.dev/en/tech/mysql/indexing/</link><pubDate>Tue, 25 Aug 2026 00:00:00 +0000</pubDate><guid>https://4f0a9a3b.wangpeng.pages.dev/en/tech/mysql/indexing/</guid><description>&lt;p&gt;Indexes are the decisive factor for MySQL query performance. Understanding InnoDB&amp;rsquo;s B+Tree index structure is the only way to write SQL that truly hits indexes.&lt;/p&gt;&#10;&lt;h2 id="btree-and-the-clustered-index"&gt;B+Tree and the Clustered Index&#10;&lt;/h2&gt;&#10;&lt;p&gt;InnoDB organizes indexes with a B+Tree whose non-leaf nodes only store index keys for navigation, while all data lives in leaf nodes that are linked in a doubly-linked list, which is ideal for range scans.&lt;/p&gt;</description></item><item><title>Transactions and Locking</title><link>https://4f0a9a3b.wangpeng.pages.dev/en/tech/mysql/transaction-lock/</link><pubDate>Tue, 25 Aug 2026 00:00:00 +0000</pubDate><guid>https://4f0a9a3b.wangpeng.pages.dev/en/tech/mysql/transaction-lock/</guid><description>&lt;p&gt;Under concurrency, transactions and locks together guarantee data consistency. InnoDB balances performance and isolation through the coordination of MVCC and locking.&lt;/p&gt;&#10;&lt;h2 id="acid-and-isolation-levels"&gt;ACID and Isolation Levels&#10;&lt;/h2&gt;&#10;&lt;p&gt;A transaction&amp;rsquo;s ACID is guaranteed by different mechanisms: atomicity by undo log, durability by redo log, isolation by MVCC and locks, and consistency is the ultimate goal.&lt;/p&gt;&#10;&lt;p&gt;The SQL standard defines four isolation levels; InnoDB defaults to &lt;code&gt;REPEATABLE READ&lt;/code&gt;:&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;READ UNCOMMITTED: possible dirty reads&lt;/li&gt;&#10;&lt;li&gt;READ COMMITTED: avoids dirty reads, possible non-repeatable reads&lt;/li&gt;&#10;&lt;li&gt;REPEATABLE READ: avoids non-repeatable reads (InnoDB additionally avoids phantom reads)&lt;/li&gt;&#10;&lt;li&gt;SERIALIZABLE: fully serial, lowest performance&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h2 id="mvcc-and-logs"&gt;MVCC and Logs&#10;&lt;/h2&gt;&#10;&lt;p&gt;MVCC (Multi-Version Concurrency Control) lets reads avoid locks and reads/writes not block each other. Each row implicitly carries &lt;code&gt;trx_id&lt;/code&gt; and &lt;code&gt;roll_pointer&lt;/code&gt;, builds historical versions via undo log, and uses a ReadView to decide whether a version is visible to the current transaction.&lt;/p&gt;</description></item></channel></rss>