question

BurtKing avatar image
0 Votes"
BurtKing asked pituach commented

What are the wait stats I can track for page compression

I am trying to track the expense of page compression in sql server with wait stats. What events should I be looking for? Ideally I'd like to understand CPU consumption.

sql-server-general
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @BurtKing,

Agree with pituach.

Quote from the blog Tracking Page Compression Operations, which share you the detail examples about this.

There isn’t really a whole lot of information about the operations of database compression that is documented as being available in the DMV’s or SQL Trace. Paul Randal pointed out on Twitter today that sys.dm_db_index_operational_stats() provides the page_compression_attempt_count and page_compression_success_count available. Beyond that the only other documented information for monitoring Data Compression are the Page Compression Attempts/sec and Pages Compressed/sec Performance Counters of the SQL Server:Access Methods object in Perfmon


0 Votes 0 ·
pituach avatar image
1 Vote"
pituach answered pituach commented

Hi,

Note: You can use sys.dm_db_index_operational_stats() which provides the page_compression_attempt_count and page_compression_success_count available.

The events which you can track are: sqlserver.page_compression_attempt_failed and sqlserver.page_compression_tracing


· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I was thinking more along the lines of finding the event in dm_os_wait_stats. Is that available? I am trying to correlate processor usage to row compression on large tables. It would appear sqlserver.page_compression_attempt_failed and sqlserver.page_compression_tracing will not do so.

0 Votes 0 ·

Hi,

dm_os_wait_stats provides the information about the waits encountered including these related to compression, but sqlserver.page_compression_attempt_failed provide the exact information only about the compression failure. Much simpler to get the "reason" out of this.


You can get information on PREEMPTIVE_OS_GETCOMPRESSEDFILESIZE and HADR_COMPRESSED_CACHE_SYNC from the dm_os_wait_stats, but a compression can lead to other type of waits in-directly, which are not unique to compression, so how can you differentiate between them? Using the sqlserver.page_compression_attempt_failed provide direct information related only to compression.

Remember that activating compression lead to more CPU uses. In addition, the more CPU core we have, the more work the server have to do to coordinate their efforts and combine their results. This might result with more CXPACKET waits for example. So... if you have sqlserver.page_compression_attempt_failed failure event, then you know that this is related to the compassion, but if you monitor many CXPACKET waits in the dm_os_wait_stats then it gives nothing directly (you can poll the data indirectly probably, for example using sqlserver.page_compression_attempt_failed which take us back to the start). To make the relation between the waits and the compression you will need to cross more information

https://docs.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-os-wait-stats-transact-sql

0 Votes 0 ·

I don't have any compression failures - I'm not looking for that. I'm trying to track how much CPU I'm consuming because I'm using compression.

1 Vote 1 ·
Show more comments
TomPhillips-1744 avatar image
0 Votes"
TomPhillips-1744 answered

I do not believe there is a wait state for that information.

Page compression only operates on an 8k page at a time. So it has very little impact, unless you are doing bulk inserts and many pages are changing.

I suggest you read this:
https://docs.microsoft.com/en-us/sql/relational-databases/data-compression/page-compression-implementation?view=sql-server-ver15#when-page-compression-occurs

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ErlandSommarskog avatar image
0 Votes"
ErlandSommarskog answered

I don't see why page compression as such would produce more waits. After all, page compression is something that happens on the CPU, and wait stats reflects what happens outside the CPU. Well, with the exception for the preemptive waits, that is, when SQL Server runs code outside SQL Server, but that is not the case here.

However, increased CPU usage does exhibit in one way in the page stats, you get more SOS_SCHEDULER_WAITs. This wait type is registered every time a process yields voluntarily to let other processes execute. If there is idle CPU, the wait as such will be short, but the number of waits will go up by one.

But I am not sure that this is the best way to track CPU usage.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.