When MySQL writes Binary Large Objects (BLOBs) in high-concurrency environments, lock contention and redo log bottlenecks are common. PolarDB uses kernel-level optimizations to resolve lock contention, I/O pressure, and space management issues during BLOB writes. These optimizations significantly improve DML and DDL performance, ensuring that your workloads run stably and efficiently in high-concurrency scenarios.
Overview
A Binary Large Object (BLOB) is a database field type used to store large data such as images, documents, and long text. In the native MySQL InnoDB engine, when a BLOB field in a data row exceeds a specific size, it is stored on separate off-page data pages. Although this mechanism can handle large data, it also introduces three major performance challenges:
Concurrent write bottleneck: Updating an off-page data page triggers a pessimistic lock, which allows only one thread at a time to write BLOBs to a table and severely limits concurrency.
Surging I/O pressure: Large fields generate bulky redo logs. If disk I/O capacity is insufficient, log flushing becomes a bottleneck and blocks foreground writes.
Delayed space reclamation: The cleanup of old BLOB data versions (Purge) is inefficient, which can cause storage space bloat and performance degradation.
PolarDB BLOB optimization is designed to resolve these issues. It optimizes the entire BLOB write, update, and reclamation path at the kernel level without changing how you use the database.
Billing
The BLOB performance optimization features are built into the PolarDB kernel and are available at no additional charge.
Optimize BLOB write performance
If you encounter write throughput bottlenecks or high concurrent write latency on BLOB tables during peak business hours, write lock contention is usually the cause. PolarDB provides page pre-allocation and index latch optimization to resolve this issue.
Page pre-allocation optimization
This optimization divides the BLOB write process into the following steps:
Calculates and allocates all the required data pages in a single batch.
Copies the data in a lock-free state, filling the newly allocated pages with the BLOB content.
Attaches the resulting chain of data pages to the index record with a single optimistic lock operation.
Throughout the write process, only the initial space allocation phase is mutually exclusive. Other time-consuming operations, such as data copying, can run concurrently with other BLOB writes. In addition, because data copying occurs outside the critical section, the system avoids the risk that a single write generates enough redo log data to fill the buffer and block writes. This mechanism minimizes global lock hold time, which significantly improves concurrent write capacity.
Index latch optimization
For tables that contain small (less than 8 KB) or mixed-size BLOB fields, native MySQL often abandons optimistic locking prematurely during updates because of index page structure changes, known as Split Merge Operations (SMOs). It then falls back to an inefficient pessimistic lock mode, which severely affects concurrent performance. Latch optimization resolves this bottleneck by completing more work on the optimistic path. This optimization works as follows:
Stay on the optimistic path: When a potential BLOB field update is detected, the optimization logic does not immediately switch to pessimistic locking. It continues to hold a shared lock (S-latch), which has a lower probability of conflict, and stays on the optimistic update path.
Pre-build and attempt the update: On the optimistic path, it pre-builds the BLOB data structure required for the update and attempts to modify the index page directly.
Evaluate, then commit or fall back:
Success: The updated record meets the space requirements of the current index page, so the operation completes quickly on the optimistic path.
Failure: If the page has insufficient space, for example, the optimization automatically abandons the attempt and falls back to the native MySQL pessimistic lock path. That path completes the entire update and ensures data consistency.
The key advantage of this optimistic attempt mechanism is that it significantly increases the success rate of optimistic updates. Many operations that would otherwise fall back to pessimistic locking can complete in a lighter, more efficient way, which greatly improves throughput for updating mixed-size BLOB data under high concurrency.
Enable write optimizations
In the PolarDB console, go to the page to view and modify the following parameters to enable these optimizations:
Parameter | Description | Supported versions |
| Enables or disables BLOB page pre-allocation optimization. Valid values:
|
|
| Sets the maximum length of a single BLOB column for BLOB page pre-allocation optimization. | |
| Enables or disables BLOB index latch optimization. |
Reduce the redo log volume of BLOB writes
If your workload writes large amounts of BLOB data, redo logs can be generated too quickly and become a system I/O bottleneck. Enable redo compression to relieve the pressure.
Redo compression compresses BLOB-related redo logs in parallel before they are written to the log buffer. This significantly reduces the actual redo log write volume, by 40% to 60% on average in tests, which lowers storage I/O pressure and prevents a redo module bottleneck from affecting overall write performance. During crash recovery, the database automatically decompresses and applies these logs.
Enable redo compression
In the PolarDB console, go to the page to view and modify the following parameters to enable this optimization:
Parameter | Description | Supported versions |
| Sets the compression algorithm for BLOB redo logs. Valid values:
|
|
| Sets the compression level of the selected compression algorithm. Valid values: 0 to 9. Default value: 6. |
Accelerate BLOB space reclamation after deletion
If tablespace reclamation is slow and files keep growing after you frequently delete or update BLOB data, the root cause is the low efficiency of the native MySQL background Purge process. When cleaning up data, this process first holds core locks, such as Index SX, before reading BLOB pages. If a page is not in memory, a time-consuming disk I/O operation occurs while the lock is held, which blocks other concurrent operations on the table for an extended period. The PolarDB Purge page pre-read optimization resolves this bottleneck by separating I/O operations from the locking process. This optimization works as follows:
Identify target pages: Before acquiring locks and starting the cleanup, the Purge process first identifies the complete chain of off-page BLOB pages that must be reclaimed.
Pre-read asynchronously: The process issues asynchronous I/O requests to load the target pages that are not yet in memory from disk into the buffer pool.
Clean up quickly: After all pages are loaded into memory, the Purge process acquires core locks, such as
Index SX, and quickly performs the page release and metadata modification operations entirely in memory.
The Purge page pre-read mechanism primarily prevents disk I/O operations from occurring in the critical section while locks are held. By moving the most time-consuming I/O operations earlier, it shortens lock hold time to just the fast in-memory operations. This improves BLOB data reclamation efficiency and prevents space bloat. More importantly, it reduces how much background cleanup blocks foreground workloads, such as high-concurrency writes. As a result, it improves the concurrency and stability of the entire database.
Enable Purge pre-read
In the PolarDB console, go to the page to view and modify the following parameter to enable this optimization:
Parameter | Description | Supported versions |
| Enables or disables page pre-read optimization during BLOB Purge. Valid values:
| Supported on all versions. |
Improve DDL execution efficiency
If you need to run DDL operations, such as ALTER TABLE, on tables that contain large amounts of BLOB data and the operations take too long, enable DDL-related BLOB optimizations to significantly reduce the operation time.
Page pre-allocation optimization: Because overflow columns of BLOB fields exist on the primary key, DDL operations that rebuild the primary table also write BLOB fields. Page pre-allocation uses a more direct and simplified locking method to write BLOB data, which avoids the overhead of handling complex concurrency conflicts and significantly improves rebuild efficiency.
Latch optimization: Because parallel DDL partitions the primary key tree, multiple worker threads do not operate on the same data page. This optimization protects the allocation of new pages independently so that other operations can run concurrently, which improves efficiency.
Redo optimization:
Page aggregation: During a bulk load, the system no longer generates a redo log entry for each record. Instead, after a data page is full, it writes the changes to the entire page as one large redo record, which improves redo operation efficiency.
Aggregate compression: The system compresses these large aggregated redo records to further reduce the redo log volume during DDL operations.
Enable DDL optimizations
In the PolarDB console, go to the page to view and modify the following parameters to enable these optimizations:
Some parameters in the following table cannot be modified manually. If you need to change them, submit a ticket to contact us.
Parameter | Description | Supported versions |
| Specifies whether to enable large field optimization during DDL operations. Valid values:
|
|
| Specifies whether to enable index latch optimization during DDL operations. Valid values:
|
|
| Specifies whether to enable redo page aggregation during DDL bulk loading. Valid values:
|
|
| Sets the redo compression algorithm for DDL bulk loading. Valid values:
|
|
| Sets the target for redo compression during DDL operations. Valid values:
|
|
Related module optimizations
In high-throughput BLOB workloads, bottlenecks can also occur in other modules. For better performance, PolarDB also combines the following optimizations:
Parallel asynchronous redo writes: The system shards the data in the redo buffer and uses multiple threads to issue asynchronous I/O tasks concurrently, which significantly increases redo log write throughput (up to 4 GB/s in tests).
File extension optimization: Built on PolarDB's self-developed distributed file system, a tablespace extension operation only needs to modify a small amount of metadata, and the native file zero-filling operation is removed. File extension time and lock overhead are no longer a bottleneck.
Lock-free dirty page flushing: This optimization uses shadow page technology. When flushing a dirty page, the system first builds an in-memory copy, releases the page lock, and then uses the copy for the I/O operation. This prevents write requests from being blocked by a page lock held during flushing.
Performance test data
The following data shows the performance improvements in DML and DDL scenarios after BLOB optimization is enabled.
DML performance In high-concurrency scenarios with row lengths of 100 KB and 200 KB, the PolarDB optimization improves insert and update performance by nearly 3x. With redo compression, performance improves by 4x to 5x.


DDL performance For a 40 GB table that contains BLOB fields, enabling these optimizations increases the DDL write rate by 5x to 6x and reduces the total time by 84%.
