search
HomeDatabaseMysql Tutorialbuffercache实验10-buffercache优化指标

标题起的有点大,不同情况的解决内容其实在前面每一小篇里都有了,没重复粘贴了。 1.buffer cache的大小: 如16CPU,32G内存: 初步分配: SGA_TARGET=16G --内存一半 BUFFER CACHE=12G ---SGA的40%起,可设置到70%-80%--保守点也可以设置到10G,后期可以根据

标题起的有点大,不同情况的解决内容其实在前面每一小篇里都有了,没重复粘贴了。大笑

1.buffer cache的大小:

如16CPU,32G内存:
初步分配:
SGA_TARGET=16G --内存一半
BUFFER CACHE=12G ---SGA的40%起,可设置到70%-80%--保守点也可以设置到10G,后期可以根据系统运行情况结合buffer pool advisory进行修改。
shared_pool=3G

当参数:statistics_level为typical 或者all;或者db_cache_advice参数设置为ON,ORACLE会根据系统负载,自动估算出当前实例的buffer cache最佳大小 --通过v$db_cache_advice;或者ASR报告中:buffer pool advisory一栏。之后可以根据建议大小结合当前系统内存使用情况设置一个合理值。
以下为我虚拟机中环境数据:--SIZE_FOR_ESTIMATE单位为M,系统当前BUFFER_CACHE大小为32M。
SYS@ bys3>select SIZE_FOR_ESTIMATE,BUFFERS_FOR_ESTIMATE,ESTD_PHYSICAL_READ_FACTOR,ESTD_PHYSICAL_READS from v$db_cache_advice;
SIZE_FOR_ESTIMATE BUFFERS_FOR_ESTIMATE ESTD_PHYSICAL_READ_FACTOR ESTD_PHYSICAL_READS
----------------- -------------------- ------------------------- -------------------
4 496 2.4576 527548
8 992 2.3653 507728
12 1488 2.2055 473442
16 1984 1.887 405072
20 2480 1.3526 290349
24 2976 1.1332 243258
28 3472 1.0613 227818
32 3968 1 214661
36 4464 .9342 200530
40 4960 .8871 190428
44 5456 .7987 171447
48 5952 .7203 154614
52 6448 .66 141675
56 6944 .6248 134123
60 7440 .5859 125766
64 7936 .5529 118684
从此视图可以看到:系统当前BUFFER_CACHE大小为32M,ESTD_PHYSICAL_READS字段是物理读的块数,ESTD_PHYSICAL_READ_FACTOR字段是物理读/逻辑读的比值,越小越好。
可以看到,BUFFER_CACHE越大,物理读块数越少,物理读/逻辑读的比值越小,所以我这实验环境是要增大BUFFER_CACHE的。可以先增加到64M,然后运行一段时间,再继续结合v$db_cache_advice视图,最终设置一个最优值。

2.buffer cache的命中率

命中率高意味着服务器进程基本上都是从 buffer cache中获取数据块。
但是有的情况下命中率并不能说明性能问题,
如大表全表扫描时buffer cache命中率会下降;
热块问题严重时,虽然buffer cache命中率是100%,性能却不佳;
执行计划出错,所涉及的数据块都在buffer cache中,命中率100%,性能不佳;

3.buffer cache的争用

主要指标是:free buffer waits/buffer busy waits
原因主要也就是:
free buffer waits-找不到空闲 buffer--buffer cache空间不足
buffer busy waits--热块争用

其实在前面的等待事件的博文中,也已经提到过详细解决思路,这里不重新贴了。
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment