DB2内存使用过高优化
最近在在做DB2的benchmark,发现数据库的内存占用特别高,因为是做benchmark测试,所以表并不多,并且主要是针对其中的一张表做测
最近在在做DB2的benchmark,发现数据库的内存占用特别高,因为是做benchmark测试,所以表并不多,并且主要是针对其中的一张表做测试,当这张表的数据快到1亿的时候,用top查询系统状态如下
# top
top - 20:06:34 up 5 days, 22:20, 12 users, load average: 18.53, 6.57, 3.19
...
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
32458 db2inst 20 0 42.3g 27g 27g S 63.7 44.3 0:27.13 db2sysc 0
...
其中db2sync进程用了27G的内存,从而导致系统物理内存几乎被用光并且系统也变的非常慢。
使用db2mtrk命令来查看db2的内存使用情况,如下:
# db2mtrk -i -d -v
Tracking Memory on: 2014/06/22 at 21:50:19
Memory for instance
Other Memory is of size 63111168 bytes
FCMBP Heap is of size 851968 bytes
Database Monitor Heap is of size 983040 bytes
Total: 64946176 bytes
Memory for database: PA913
Backup/Restore/Util Heap is of size 65536 bytes
Package Cache is of size 262144 bytes
Other Memory is of size 196608 bytes
Catalog Cache Heap is of size 262144 bytes
Buffer Pool Heap (1) is of size 24465047552 bytes
Buffer Pool Heap (System 32k buffer pool) is of size 1835008 bytes
Buffer Pool Heap (System 16k buffer pool) is of size 1572864 bytes
Buffer Pool Heap (System 8k buffer pool) is of size 1441792 bytes
Buffer Pool Heap (System 4k buffer pool) is of size 1376256 bytes
Shared Sort Heap is of size 0 bytes
Lock Manager Heap is of size 3881172992 bytes
Database Heap is of size 94830592 bytes
Application Heap (47) is of size 131072 bytes
Application Heap (45) is of size 65536 bytes
Application Heap (44) is of size 65536 bytes
Application Heap (43) is of size 65536 bytes
Application Heap (42) is of size 65536 bytes
Application Heap (41) is of size 65536 bytes
Application Heap (40) is of size 65536 bytes
Application Heap (39) is of size 65536 bytes
Application Heap (38) is of size 65536 bytes
Application Heap (37) is of size 65536 bytes
Application Heap (36) is of size 65536 bytes
Application Heap (35) is of size 65536 bytes
Application Heap (34) is of size 65536 bytes
Application Heap (33) is of size 65536 bytes
Application Heap (32) is of size 65536 bytes
Application Heap (31) is of size 65536 bytes
Application Heap (30) is of size 65536 bytes
Application Heap (29) is of size 65536 bytes
Application Heap (28) is of size 65536 bytes
Application Heap (27) is of size 65536 bytes
Application Heap (26) is of size 65536 bytes
Application Heap (25) is of size 65536 bytes
Application Heap (24) is of size 65536 bytes
Application Heap (23) is of size 65536 bytes
Application Heap (22) is of size 65536 bytes
Application Heap (21) is of size 65536 bytes
Application Heap (20) is of size 65536 bytes
Application Heap (19) is of size 65536 bytes
Application Heap (18) is of size 65536 bytes
Application Heap (17) is of size 65536 bytes
Application Heap (16) is of size 65536 bytes
Application Heap (15) is of size 65536 bytes
Application Heap (14) is of size 65536 bytes
Application Heap (13) is of size 65536 bytes
Application Heap (12) is of size 65536 bytes
Application Heap (11) is of size 196608 bytes
Application Heap (10) is of size 65536 bytes
Application Heap (9) is of size 65536 bytes
Application Heap (8) is of size 65536 bytes
Application Heap (7) is of size 131072 bytes
Applications Shared Heap is of size 393216 bytes
Total: 28451340288 bytes
其中重点是“Memory for database: PA913”下的“Buffer Pool Heap (1) is of size 24465047552 bytes”,用了近25G的内存,由于我确定我的数据库中的数据量不是很大,所以减少数据库内存就是我的首选了。
查了一下资料,可以通过修改database_memory系统参数来设置数据库内存的使用。默认情况下database_memory的设置是AUTOMATIC,这里可以通过下面的命令来修改参数,,修改完后要重新启动db2
$ db2 update db cfg for
$ db2stop force
$ db2start
数据库重启后,先用客户端连接一下数据库,然后再使用“db2mtrk -i -d -v”查看内存使用情况,就发现内存就会有明显的下降。用top查看结果也类似。
在真实的DB2使用情况下,修改这个值是需要慎重的,可以参考下面列出的参考资料。
本文永久更新链接地址:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The amount of memory required by Oracle depends on database size, activity level, and required performance level: for storing data buffers, index buffers, executing SQL statements, and managing the data dictionary cache. The exact amount is affected by database size, activity level, and required performance level. Best practices include setting the appropriate SGA size, sizing SGA components, using AMM, and monitoring memory usage.

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

To handle database connection errors in PHP, you can use the following steps: Use mysqli_connect_errno() to obtain the error code. Use mysqli_connect_error() to get the error message. By capturing and logging these error messages, database connection issues can be easily identified and resolved, ensuring the smooth running of your application.

Using the database callback function in Golang can achieve: executing custom code after the specified database operation is completed. Add custom behavior through separate functions without writing additional code. Callback functions are available for insert, update, delete, and query operations. You must use the sql.Exec, sql.QueryRow, or sql.Query function to use the callback function.

Through the Go standard library database/sql package, you can connect to remote databases such as MySQL, PostgreSQL or SQLite: create a connection string containing database connection information. Use the sql.Open() function to open a database connection. Perform database operations such as SQL queries and insert operations. Use defer to close the database connection to release resources.

Use the DataAccessObjects (DAO) library in C++ to connect and operate the database, including establishing database connections, executing SQL queries, inserting new records and updating existing records. The specific steps are: 1. Include necessary library statements; 2. Open the database file; 3. Create a Recordset object to execute SQL queries or manipulate data; 4. Traverse the results or update records according to specific needs.

How to integrate GoWebSocket with a database: Set up a database connection: Use the database/sql package to connect to the database. Store WebSocket messages to the database: Use the INSERT statement to insert the message into the database. Retrieve WebSocket messages from the database: Use the SELECT statement to retrieve messages from the database.
