0
DBA: Boost Your Server
Reader Writer Blocking                                                 Tran2 (Select)Tran1 (Update)                 X-Lock...
Read Committed Snapshot•   New “flavor” of read committed    • Turn ON/OFF on a database•   Readers see committed values a...
Demo: RCSI
Lock Escalation       HOBT         T1: IX                            T1: XPage    Page        Page     T1: IX             ...
Lock Escalation• Converting finer-grain locks to coarse grain locks.   • Row to Table   • Page to Table.• Benefits   • Red...
Partitioned Tables and Indexes•   SQL Server 2005 introduced partitioning, which some    customers use to scale a query wo...
Lock Escalation: The Problem•   Lock escalation on partitioned tables reduces concurrency as the table lock locks    ALL p...
Lock Escalation: The Solution•   SQL Server 2008 & up allows lock escalation to the partition level,    allowing concurren...
Demo: PartitionLevel LockEscalation
Filtered Indexes• An index with a WHERE clause to specify a  criteria• Essentially index only a subset of a the table  • Q...
Using Filtered Indexes• Advantages of Filtered Indexes  • Improve query performance, partly by    enhancing execution plan...
Using Filtered Indexes• Scenarios for Filtered Indexes  • Sparse columns, where most data is null  • Columns with categori...
Demo:FilteredIndexes
Optimize for ad hoc workloads• New server option in    • SP_CONFIGURE show advanced  SQL Server 2008           options,1  ...
How good is it?
Demo:Optimize for  ad hoc workload
Configuration:  Don’t get confused!
Configuratio n Cheats
Processor Funny Games
TempDB• Create a file per CPU that SQL Server uses• Not more than 8
Memory Configuration• X86? Really?  • Microsoft Knowledge Base article 274750
Lock Pages in Memory• Yes/No?• Enterprise Edition only  • Can be done on Standard using latest SPs for    2005/2008 and tr...
Min/Max Memory• Yes/No?
Min/Max Memory
Min/Max Memory• Yes/No?• Keep an eye on Available MB counter
Reason and Solution?• Note the name Memory (Private Working  Set) –  • AWE APIs are used on 64bit to “lock” pages  • That ...
Demo:Lock Pages in Memory
Compression
As data volume grows…• Large databases =   • Storage Cost   • Workload      Performance  •   Manageability      Cost  •   ...
Compression• Store data efficiently in the  row/page  • (+) More data can fit in    memory  • (+) Better Performance for I...
Data Compression• SQL Server 2008  • ROW and PAGE compression  • Backup Compression• SQL Server 2008 R2  • Unicode compres...
Enabling Compression:               Microsoft’s Perspective                                             Uncompressed• Late...
Should it be so complex?In real life – usually compress the entire large          tables using page compression…
Summary – Compression•   Can reduce size of database significantly•   Lower total cost of ownership (TCO)•   Easy to enabl...
Demo:Compression
SQL Explore 2012: P&T Part 3
SQL Explore 2012: P&T Part 3
Upcoming SlideShare
Loading in...5
×

SQL Explore 2012: P&T Part 3

826

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
826
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • No escalation from Row to PageEach lock structure is 100 bytesNumber of locks acquired on a rowset > 5000 - Periodically after that
  • Self-explanatory. See Books Online for more details about partitioning. Also see http://msdn2.microsoft.com/en-us/library/ms345146.aspx
  • Query 1 is updating partition 1. It hits the escalation threshold and escalates to a TABLE X lock. Query 2 tries to update partition 3 and can’t because of the table X lock, even though nothing in partition 3 is being altered by query 1.
  • Instead of escalating to the table level and blocking all other queries on the table, you can now choose to have escalation to the partition level, which allows concurrent queries on different partitions.
  • Transcript of "SQL Explore 2012: P&T Part 3"

    1. 1. DBA: Boost Your Server
    2. 2. Reader Writer Blocking Tran2 (Select)Tran1 (Update) X-Lock Row-1 S-Lock Blocked
    3. 3. Read Committed Snapshot• New “flavor” of read committed • Turn ON/OFF on a database• Readers see committed values as of beginning of statement • Writers do not block Readers • Readers do not block Writers • Writers do block writers• Can greatly reduce locking / deadlocking without changing applications
    4. 4. Demo: RCSI
    5. 5. Lock Escalation HOBT T1: IX T1: XPage Page Page T1: IX T1: X T1: X T1: X T1: XRow Row Row T1: X T1: X T1: X T1: X
    6. 6. Lock Escalation• Converting finer-grain locks to coarse grain locks. • Row to Table • Page to Table.• Benefits • Reduced locking overhead • Reduces Memory requirement• Triggered when • Number of locks acquired on a rowset > 5000 • Memory pressure
    7. 7. Partitioned Tables and Indexes• SQL Server 2005 introduced partitioning, which some customers use to scale a query workload • Another common use is to streamline maintenance and enable fast range inserts and removals from tables Partitioned Table FG1 FG2 FG3
    8. 8. Lock Escalation: The Problem• Lock escalation on partitioned tables reduces concurrency as the table lock locks ALL partitions Query 1 Partitioned Query 2 IX X Table update update Partition 1 Partition 2 Partition 3 FG1 FG2 FG3• Only way to solve this in SQL Server 2005 is to disable lock escalation
    9. 9. Lock Escalation: The Solution• SQL Server 2008 & up allows lock escalation to the partition level, allowing concurrent access to other partitions Query 1 Partitioned Query 2 IX Table update update Partition 1 X Partition 2 Partition 3 FG1 FG2 FG3• Escalation to partition level does not block queries on other partitions
    10. 10. Demo: PartitionLevel LockEscalation
    11. 11. Filtered Indexes• An index with a WHERE clause to specify a criteria• Essentially index only a subset of a the table • Query optimizer most likely to use when WHERE clause matches that of the filtered index
    12. 12. Using Filtered Indexes• Advantages of Filtered Indexes • Improve query performance, partly by enhancing execution plan quality • Smaller index maintenance costs • Less disk storage
    13. 13. Using Filtered Indexes• Scenarios for Filtered Indexes • Sparse columns, where most data is null • Columns with categories of values • Columns with distinct ranges of values
    14. 14. Demo:FilteredIndexes
    15. 15. Optimize for ad hoc workloads• New server option in • SP_CONFIGURE show advanced SQL Server 2008 options,1 RECONFIGURE• Only a stub is cached GO • SP_CONFIGURE optimize for ad on first execution hoc workloads,1 RECONFIGURE• Full plan cached GO after second execution
    16. 16. How good is it?
    17. 17. Demo:Optimize for ad hoc workload
    18. 18. Configuration: Don’t get confused!
    19. 19. Configuratio n Cheats
    20. 20. Processor Funny Games
    21. 21. TempDB• Create a file per CPU that SQL Server uses• Not more than 8
    22. 22. Memory Configuration• X86? Really? • Microsoft Knowledge Base article 274750
    23. 23. Lock Pages in Memory• Yes/No?• Enterprise Edition only • Can be done on Standard using latest SPs for 2005/2008 and trace flag 845 for 2008 R2• AWE is ignored in 64 bit• The ‘Local System’ account has the ‘lock pages in memory’ privilege by default• Configure MaxServerMemory
    24. 24. Min/Max Memory• Yes/No?
    25. 25. Min/Max Memory
    26. 26. Min/Max Memory• Yes/No?• Keep an eye on Available MB counter
    27. 27. Reason and Solution?• Note the name Memory (Private Working Set) – • AWE APIs are used on 64bit to “lock” pages • That memory is not part of the working set• Only trust: • Perfmon SQL Server memory counters • sys.dm_os_process_memory DMV
    28. 28. Demo:Lock Pages in Memory
    29. 29. Compression
    30. 30. As data volume grows…• Large databases = • Storage Cost • Workload Performance • Manageability Cost • Backup/Recovery
    31. 31. Compression• Store data efficiently in the row/page • (+) More data can fit in memory • (+) Better Performance for I/O bound workload • (-) Performance degradation for CPU bound workload
    32. 32. Data Compression• SQL Server 2008 • ROW and PAGE compression • Backup Compression• SQL Server 2008 R2 • Unicode compression• SQL Server 2008 R2 • Spatial indexes compression
    33. 33. Enabling Compression: Microsoft’s Perspective Uncompressed• Latest partition uncompressed PAGE Compressed ROW Compressed Jan-Mar Apr-June July-Sept Oct-Dec
    34. 34. Should it be so complex?In real life – usually compress the entire large tables using page compression…
    35. 35. Summary – Compression• Can reduce size of database significantly• Lower total cost of ownership (TCO)• Easy to enable/disable• No application changes• Performance gains!
    36. 36. Demo:Compression
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×