10

Click here to load reader

SQL Server Memory Pressure

Embed Size (px)

Citation preview

Page 1: SQL Server Memory Pressure

SQL SERVER MEMORY PRESSURE

By Hamid J. FardMicrosoft Certified Master: SQL Server 2008

Microsoft Certified Solutions Master: Charter-Data PlatformCIW Database Design Specialist

Copyrights © 2016 Fard Solutions Sdn Bhd, All rights reserved.

Page 2: SQL Server Memory Pressure

Agenda• SQL Server Internal Architecture (Overview)• SQL Server Plan Cache Internals• SQL Server Plan Cache Size Management• SQL Server Local Memory Pressure• SQL Server Global Memory Pressure• SQL Server Plan Cache Entries Cost

Copyrights © 2016 Fard Solutions Sdn Bhd, All rights reserved.

Page 3: SQL Server Memory Pressure

SQL Server Internal Architecture (Overview)

Copyrights © 2016 Fard Solutions Sdn Bhd, All rights reserved.

Plan Cache

Buffer Pool

Available Memory

D

ProtocolLayerRelational Engine

(OLEDB)

Storage EngineData File

SNIQuery

Executor

CommandParser

Optimizer

Buffer Manager

AccessMethods

TDS

Language EventQuery Tree

Query PlanTDS

Log File

TransactionManager

Client

Page 4: SQL Server Memory Pressure

SQL Server Plan Cache Internals

Copyrights © 2016 Fard Solutions Sdn Bhd, All rights reserved.

Plan Cache

Buffer Pool

Available Memory

CACHESTORE_OBJCP

CACHESTORE_SQLCP

CACHESTORE_PHDR

CACHESTORE_XPPROC

CACHESTORE_*

Execution Context

Execution Plans

SQL MGR

Plan Cache Metadata DMVs / DMFssys.dm_exec_sql_textsys.dm_exec_cached_planssys.dm_exec_cached_plan_dependent_objectssys.dm_exec_requestssys.dm_exec_query_stats

Page 5: SQL Server Memory Pressure

SQL Server Plan Cache Size Management

Copyrights © 2016 Fard Solutions Sdn Bhd, All rights reserved.

SQL Server 2005 RTM and SQL Server 2005 SP175% of visible target memory from 0 – 8 GB + 50% of visible target memory from 8 – 64GB + 25% of visible target memory > 64GB

SQL Server 2005 SP2 and SQL Server 2008 75% of visible target memory from 0-4GB + 10% of visible target memory from 4Gb-64GB + 5% of visible target memory > 64GB

SQL Server 2012 and SQL Server 201475% of visible target memory from 0-4GB + 10% of visible target memory from 4Gb-64GB + 5% of visible target memory > 64GB

Page 6: SQL Server Memory Pressure

CACHESTORE_SQLCP

40% FullNormal Memory

Pressure

75% FullLocal Memory

Pressure Occurred

SQL Server Local Memory Pressure

Copyrights © 2016 Fard Solutions Sdn Bhd, All rights reserved.

Adhoc Query Plan

The queries below can be used to determine the number of buckets in the hash tables for the object store and the SQL store, and the number of entries in each of those stores.

SELECT type as 'plan cache store', buckets_count FROM sys.dm_os_memory_cache_hash_tablesWHERE type IN ('CACHESTORE_OBJCP', 'CACHESTORE_SQLCP'); SELECT type, count(*) total_entries FROM sys.dm_os_memory_cache_entries WHERE type IN ('CACHESTORE_SQLCP', 'CACHESTORE_OBJCP') GROUP BY type;

Page 7: SQL Server Memory Pressure

SQL Server Global Memory Pressure

Copyrights © 2016 Fard Solutions Sdn Bhd, All rights reserved.

External Internal

When the operating system determines that the SQL Server process needs to reduce its physical memory consumption because of competing needs from other processes on the server.

When the memory broker predicts that all cache stores combined will use more than 80 percent of the cache plan pressure limit.

Page 8: SQL Server Memory Pressure

Plan Cache Store (SQLCP)

Plan A1

SQL Server Plan Cache Entries Cost

Copyrights © 2016 Fard Solutions Sdn Bhd, All rights reserved.

Use Plan Plan A2

Plan Cache Store (OBJCP)

Plan AIO: 5

Context Switch: 6Memory: 12

Cost: 5+6+12 = 23

Create Plan

Page 9: SQL Server Memory Pressure

Conclusion• Local Memory Pressure Can Increase The Respond Time Of Query

Execution.• Global Memory Pressure Can Reduce The Overall System

Performance And Increases The I/O Operations.• Both Local And Global Memory Pressure Can Increase The

Processor Usage.• Plan Cache Stores Are Out Of Buffer Pool Sections, Configure SQL

Server Memory To Provide Enough Space For Plan Caches.

Copyrights © 2016 Fard Solutions Sdn Bhd, All rights reserved.

Page 10: SQL Server Memory Pressure

Contact for Expert Advice

Copyrights © 2016 Fard Solutions Sdn Bhd, All rights reserved.

Fard Solutions Sdn Bhd1-1C, Incubator 1, Technology Park Malaysia, Bukit Jalil, 57000 Kuala Lumpur, Malaysia.Tel: +603-89946788 - +603-79725433Web: www.Fard-Solutions.comEmail: [email protected]

Contact Us For 30 Minutes Free Consultation.