Document Database Service

Improving Read/Write Performance of Database

2025-07-16 06:28:01

Common ways to improve database read and write performance:

  1. Using indexes: Make sure your document database service has the appropriate indexes in its database to speed up queries. Create appropriate indexes based on query mode and data access mode to avoid a full table scan.

  2. Write optimization:

    1. Bulk write: For large data write operations, bulk write can reduce the number of write operations and improve the write performance.

    2. Using Unordered Bulk Write: For bulk write operations that are sequentially executed, Unordered Bulk Write improves the write performance.

    3. Disabling journal: For write intensive scenarios, consider disabling the write journal to improve the write performance. However, the data durability must be weighed against the risk of data loss.

  3. Read optimization:

    1. R/W splitting: If there are highly concurrent read requests, you can use the read/write splitting policy to distribute the read requests to multiple Secondary nodes to reduce the read load on the Primary node.

    2. Selecting appropriate Read Preference: In the read operations, select the appropriate Read Preference according to the data consistency requirements to balance the performance and data consistency.

  4. Adjusting the size of connection pool: Adjust the size of the connection pool of the DDS appropriately based on the number of concurrent connections of your application and server hardware resources to avoid connection resource waste and performance bottlenecks.

  5. Using the WiredTiger storage engine: The WiredTiger storage engine generally outperforms the MMAPv1 engine in terms of performance and storage capability. For most of applications, the WiredTiger storage engine is recommended.

  6. Sharding: If the data is very large in size, you can use the sharded cluster of the DDS to distribute the data across multiple nodes to achieve scale out and load balancing.

  7. Hardware upgrading: Ensure that the document database service is running on well-performing hardware, including CPU, memory, and disk. SSDs are generally better suited to document databases than traditional mechanical HDDs because they can provide higher read and write speeds.

  8. Maintenance: Regularly maintain databases by index reconstruction, data compression, and log clearing, to improve database performance.


HLCPDWxaf4_r