How can I see if the data in a SQL Server table is page-compressed?Can I bulk insert into an empty...

Does an object storing more internal energy emit more thermal radiation?

Can lodestones be used to magnetize crude iron weapons?

Transition to "Starvation Mode" in Survival Situations

Why does Japan use the same type of AC power outlet as the US?

What is a "soap"?

Are there really no countries that protect Freedom of Speech as the United States does?

Is it possible to grow new organs through exposure to radioactivity?

How was the murder committed?

Did Pope Urban II issue the papal bull "terra nullius" in 1095?

Are employers legally allowed to pay employees in goods and services equal to or greater than the minimum wage?

Why does the cable resistance jump from a low value to high value at a particular frequency?

Did DOS zero out the BSS area when it loaded a program?

How far did Gandalf and the Balrog drop from the bridge in Moria?

Is there a way to proportionalize fixed costs in a MILP?

Are there any lower-level means of travelling between planes of existence?

A torrent of foreign terms

Escape Velocity - Won't the orbital path just become larger with higher initial velocity?

Why aren’t there water shutoff valves for each room?

How did Arecibo detect methane lakes on Titan, and image Saturn's rings?

How would armour (and combat) change if the fighter didn't need to actually wear it?

Does an Irish VISA WARNING count as "refused entry at the border of any country other than the UK?"

Pokemon Go: Gym Badge Over-completed?

What kind of liquid can be seen 'leaking' from the upper surface of the wing of a Boeing 737-800?

Help, I cannot decide when to start the story



How can I see if the data in a SQL Server table is page-compressed?


Can I bulk insert into an empty page-compressed table and get full compression?SQL 2008 Merge Replication and table-level data compressionWhy 2 allocation units during online index rebuild to different file group?Is SQL Server data compression categorically good for read-only databases?Should I add page level compression before adding the primary key, or after?SQL Server Compression Estimate Is Significantly Lower When Estimating Current Compression TypeImporting Data in Parallel in SQL ServerFind uncompressed size of all tables in a databaseSQL Server Bulk Insert properly interprets some Unicode characters but not others?how to find tables with either sparse or a column set column?Can I bulk insert into an empty page-compressed table and get full compression?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







7















This is a follow-on question to a question which I asked yesterday: Can I bulk insert into an empty page-compressed table and get full compression? The answer to that question (paraphrased from Randi Vertongen's excellent answer) is yes, but it requires that the bulk insert take a table-level lock; otherwise, the bulk insert takes a row-level lock and performs only row data compression. This raises the question: how can I tell afterward what compression is applied?



Here are the steps to create row-compressed data in a theoretically-page-compressed table:

1. Create a table with DATA_COMPRESSION=PAGE and do not use sp_tableoption to turn on the "table lock on bulk load" option for this table.

2. Use bcp to bulk insert the data from a flat file into the new table, but without specifying the -h TABLOCK option to lock the table.



The result is a table in which the data is compressed on the row level (smaller than an uncompressed table but larger than a page-compressed table), but inspecting the sys.allocation_units catalog table shows the data compression as page.



The question



When the table's data allocation is for page compression as in this scenario, what can I do to find out if the data in that table is page-compressed?










share|improve this question







New contributor



Caitlin M. Shaw is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






















  • Also for SQL 2016+ you should consider a clustered columnstore index for scenarios involving bulk loading and compression.

    – David Browne - Microsoft
    yesterday


















7















This is a follow-on question to a question which I asked yesterday: Can I bulk insert into an empty page-compressed table and get full compression? The answer to that question (paraphrased from Randi Vertongen's excellent answer) is yes, but it requires that the bulk insert take a table-level lock; otherwise, the bulk insert takes a row-level lock and performs only row data compression. This raises the question: how can I tell afterward what compression is applied?



Here are the steps to create row-compressed data in a theoretically-page-compressed table:

1. Create a table with DATA_COMPRESSION=PAGE and do not use sp_tableoption to turn on the "table lock on bulk load" option for this table.

2. Use bcp to bulk insert the data from a flat file into the new table, but without specifying the -h TABLOCK option to lock the table.



The result is a table in which the data is compressed on the row level (smaller than an uncompressed table but larger than a page-compressed table), but inspecting the sys.allocation_units catalog table shows the data compression as page.



The question



When the table's data allocation is for page compression as in this scenario, what can I do to find out if the data in that table is page-compressed?










share|improve this question







New contributor



Caitlin M. Shaw is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






















  • Also for SQL 2016+ you should consider a clustered columnstore index for scenarios involving bulk loading and compression.

    – David Browne - Microsoft
    yesterday














7












7








7








This is a follow-on question to a question which I asked yesterday: Can I bulk insert into an empty page-compressed table and get full compression? The answer to that question (paraphrased from Randi Vertongen's excellent answer) is yes, but it requires that the bulk insert take a table-level lock; otherwise, the bulk insert takes a row-level lock and performs only row data compression. This raises the question: how can I tell afterward what compression is applied?



Here are the steps to create row-compressed data in a theoretically-page-compressed table:

1. Create a table with DATA_COMPRESSION=PAGE and do not use sp_tableoption to turn on the "table lock on bulk load" option for this table.

2. Use bcp to bulk insert the data from a flat file into the new table, but without specifying the -h TABLOCK option to lock the table.



The result is a table in which the data is compressed on the row level (smaller than an uncompressed table but larger than a page-compressed table), but inspecting the sys.allocation_units catalog table shows the data compression as page.



The question



When the table's data allocation is for page compression as in this scenario, what can I do to find out if the data in that table is page-compressed?










share|improve this question







New contributor



Caitlin M. Shaw is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











This is a follow-on question to a question which I asked yesterday: Can I bulk insert into an empty page-compressed table and get full compression? The answer to that question (paraphrased from Randi Vertongen's excellent answer) is yes, but it requires that the bulk insert take a table-level lock; otherwise, the bulk insert takes a row-level lock and performs only row data compression. This raises the question: how can I tell afterward what compression is applied?



Here are the steps to create row-compressed data in a theoretically-page-compressed table:

1. Create a table with DATA_COMPRESSION=PAGE and do not use sp_tableoption to turn on the "table lock on bulk load" option for this table.

2. Use bcp to bulk insert the data from a flat file into the new table, but without specifying the -h TABLOCK option to lock the table.



The result is a table in which the data is compressed on the row level (smaller than an uncompressed table but larger than a page-compressed table), but inspecting the sys.allocation_units catalog table shows the data compression as page.



The question



When the table's data allocation is for page compression as in this scenario, what can I do to find out if the data in that table is page-compressed?







sql-server sql-server-2016 compression






share|improve this question







New contributor



Caitlin M. Shaw is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question







New contributor



Caitlin M. Shaw is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question






New contributor



Caitlin M. Shaw is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked yesterday









Caitlin M. ShawCaitlin M. Shaw

753 bronze badges




753 bronze badges




New contributor



Caitlin M. Shaw is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




Caitlin M. Shaw is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • Also for SQL 2016+ you should consider a clustered columnstore index for scenarios involving bulk loading and compression.

    – David Browne - Microsoft
    yesterday



















  • Also for SQL 2016+ you should consider a clustered columnstore index for scenarios involving bulk loading and compression.

    – David Browne - Microsoft
    yesterday

















Also for SQL 2016+ you should consider a clustered columnstore index for scenarios involving bulk loading and compression.

– David Browne - Microsoft
yesterday





Also for SQL 2016+ you should consider a clustered columnstore index for scenarios involving bulk loading and compression.

– David Browne - Microsoft
yesterday










2 Answers
2






active

oldest

votes


















12














To see whether or not data pages are indeed currently "PAGE" compressed, you can use the undocumented DMF sys.dm_db_database_page_allocations(). The is_page_compressed field contains the info you are looking for. You will need to use the DETAILED mode (i.e. 5th parameter) or else the values in that field will all be NULL.



To be clear (based on the wording of the question being, "what can I do to find out if the data in that table is page-compressed?"), this is not an all-or-none issue: page compression is applied per each data page, hence you can have none that are compressed, all being compressed, or any combination in between. So, you need to look at all of the pages. And no, you cannot necessarily assume that a single non-page compressed page indicates that you need to REBUILD because a non-filled page will not compress.



For example:



SELECT [is_page_compressed]
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED');


The following shows that the data pages are not initially page compressed, but they are after the REBUILD operation:



USE [tempdb];

-- DROP TABLE dbo.CompressedHeap;
CREATE TABLE dbo.CompressedHeap
(
ID INT IDENTITY(1, 1) NOT NULL,
String sysname,
[MaxLength] SMALLINT,
[Type] VARCHAR(5)
) WITH (DATA_COMPRESSION = PAGE);


INSERT INTO dbo.CompressedHeap ([String], [MaxLength], [Type])
SELECT col.[name], col.[max_length], obj.[type]
FROM master.sys.columns col
CROSS JOIN master.sys.objects obj;


SELECT [is_page_compressed], *
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED')
WHERE [is_iam_page] = 0
AND [is_allocated] = 1;
-- 394 pages


ALTER TABLE dbo.CompressedHeap REBUILD;


SELECT [is_page_compressed], *
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED')
WHERE [is_iam_page] = 0
AND [is_allocated] = 1;
-- 179 pages





share|improve this answer























  • 1





    That is exactly what I need, thank you so much! I checked some of my actual tables and the ones loaded without the table lock have 0% of pages compressed while the new ones that I loaded with the table lock have 99.8% of the pages compressed (and far fewer of them), just as you describe.

    – Caitlin M. Shaw
    22 hours ago



















0














You can find the compression level in the sys.partitions dmv



SELECT t.name AS tablename,
i.name AS indexname,
p.data_compression_desc
FROM sys.tables AS t
INNER JOIN sys.indexes AS i
ON t.object_id = i.object_id
INNER JOIN sys.partitions AS p
ON i.object_id = p.object_id
AND i.index_id = p.index_id;





share|improve this answer





















  • 1





    Sadly, this is a scenario in which the actual compression on the data pages is not what's listed in sys.partitions.

    – Caitlin M. Shaw
    22 hours ago






  • 1





    Hi Bob (and @CaitlinM.Shaw ): the value in sys.partitions should be the requested / ideal data compression type. But since that value is just at the partition level, it can't show the per-page current value, nor the per-row current value, both of which can vary within each partition.

    – Solomon Rutzky
    14 hours ago














Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Caitlin M. Shaw is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f245254%2fhow-can-i-see-if-the-data-in-a-sql-server-table-is-page-compressed%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









12














To see whether or not data pages are indeed currently "PAGE" compressed, you can use the undocumented DMF sys.dm_db_database_page_allocations(). The is_page_compressed field contains the info you are looking for. You will need to use the DETAILED mode (i.e. 5th parameter) or else the values in that field will all be NULL.



To be clear (based on the wording of the question being, "what can I do to find out if the data in that table is page-compressed?"), this is not an all-or-none issue: page compression is applied per each data page, hence you can have none that are compressed, all being compressed, or any combination in between. So, you need to look at all of the pages. And no, you cannot necessarily assume that a single non-page compressed page indicates that you need to REBUILD because a non-filled page will not compress.



For example:



SELECT [is_page_compressed]
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED');


The following shows that the data pages are not initially page compressed, but they are after the REBUILD operation:



USE [tempdb];

-- DROP TABLE dbo.CompressedHeap;
CREATE TABLE dbo.CompressedHeap
(
ID INT IDENTITY(1, 1) NOT NULL,
String sysname,
[MaxLength] SMALLINT,
[Type] VARCHAR(5)
) WITH (DATA_COMPRESSION = PAGE);


INSERT INTO dbo.CompressedHeap ([String], [MaxLength], [Type])
SELECT col.[name], col.[max_length], obj.[type]
FROM master.sys.columns col
CROSS JOIN master.sys.objects obj;


SELECT [is_page_compressed], *
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED')
WHERE [is_iam_page] = 0
AND [is_allocated] = 1;
-- 394 pages


ALTER TABLE dbo.CompressedHeap REBUILD;


SELECT [is_page_compressed], *
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED')
WHERE [is_iam_page] = 0
AND [is_allocated] = 1;
-- 179 pages





share|improve this answer























  • 1





    That is exactly what I need, thank you so much! I checked some of my actual tables and the ones loaded without the table lock have 0% of pages compressed while the new ones that I loaded with the table lock have 99.8% of the pages compressed (and far fewer of them), just as you describe.

    – Caitlin M. Shaw
    22 hours ago
















12














To see whether or not data pages are indeed currently "PAGE" compressed, you can use the undocumented DMF sys.dm_db_database_page_allocations(). The is_page_compressed field contains the info you are looking for. You will need to use the DETAILED mode (i.e. 5th parameter) or else the values in that field will all be NULL.



To be clear (based on the wording of the question being, "what can I do to find out if the data in that table is page-compressed?"), this is not an all-or-none issue: page compression is applied per each data page, hence you can have none that are compressed, all being compressed, or any combination in between. So, you need to look at all of the pages. And no, you cannot necessarily assume that a single non-page compressed page indicates that you need to REBUILD because a non-filled page will not compress.



For example:



SELECT [is_page_compressed]
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED');


The following shows that the data pages are not initially page compressed, but they are after the REBUILD operation:



USE [tempdb];

-- DROP TABLE dbo.CompressedHeap;
CREATE TABLE dbo.CompressedHeap
(
ID INT IDENTITY(1, 1) NOT NULL,
String sysname,
[MaxLength] SMALLINT,
[Type] VARCHAR(5)
) WITH (DATA_COMPRESSION = PAGE);


INSERT INTO dbo.CompressedHeap ([String], [MaxLength], [Type])
SELECT col.[name], col.[max_length], obj.[type]
FROM master.sys.columns col
CROSS JOIN master.sys.objects obj;


SELECT [is_page_compressed], *
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED')
WHERE [is_iam_page] = 0
AND [is_allocated] = 1;
-- 394 pages


ALTER TABLE dbo.CompressedHeap REBUILD;


SELECT [is_page_compressed], *
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED')
WHERE [is_iam_page] = 0
AND [is_allocated] = 1;
-- 179 pages





share|improve this answer























  • 1





    That is exactly what I need, thank you so much! I checked some of my actual tables and the ones loaded without the table lock have 0% of pages compressed while the new ones that I loaded with the table lock have 99.8% of the pages compressed (and far fewer of them), just as you describe.

    – Caitlin M. Shaw
    22 hours ago














12












12








12







To see whether or not data pages are indeed currently "PAGE" compressed, you can use the undocumented DMF sys.dm_db_database_page_allocations(). The is_page_compressed field contains the info you are looking for. You will need to use the DETAILED mode (i.e. 5th parameter) or else the values in that field will all be NULL.



To be clear (based on the wording of the question being, "what can I do to find out if the data in that table is page-compressed?"), this is not an all-or-none issue: page compression is applied per each data page, hence you can have none that are compressed, all being compressed, or any combination in between. So, you need to look at all of the pages. And no, you cannot necessarily assume that a single non-page compressed page indicates that you need to REBUILD because a non-filled page will not compress.



For example:



SELECT [is_page_compressed]
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED');


The following shows that the data pages are not initially page compressed, but they are after the REBUILD operation:



USE [tempdb];

-- DROP TABLE dbo.CompressedHeap;
CREATE TABLE dbo.CompressedHeap
(
ID INT IDENTITY(1, 1) NOT NULL,
String sysname,
[MaxLength] SMALLINT,
[Type] VARCHAR(5)
) WITH (DATA_COMPRESSION = PAGE);


INSERT INTO dbo.CompressedHeap ([String], [MaxLength], [Type])
SELECT col.[name], col.[max_length], obj.[type]
FROM master.sys.columns col
CROSS JOIN master.sys.objects obj;


SELECT [is_page_compressed], *
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED')
WHERE [is_iam_page] = 0
AND [is_allocated] = 1;
-- 394 pages


ALTER TABLE dbo.CompressedHeap REBUILD;


SELECT [is_page_compressed], *
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED')
WHERE [is_iam_page] = 0
AND [is_allocated] = 1;
-- 179 pages





share|improve this answer















To see whether or not data pages are indeed currently "PAGE" compressed, you can use the undocumented DMF sys.dm_db_database_page_allocations(). The is_page_compressed field contains the info you are looking for. You will need to use the DETAILED mode (i.e. 5th parameter) or else the values in that field will all be NULL.



To be clear (based on the wording of the question being, "what can I do to find out if the data in that table is page-compressed?"), this is not an all-or-none issue: page compression is applied per each data page, hence you can have none that are compressed, all being compressed, or any combination in between. So, you need to look at all of the pages. And no, you cannot necessarily assume that a single non-page compressed page indicates that you need to REBUILD because a non-filled page will not compress.



For example:



SELECT [is_page_compressed]
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED');


The following shows that the data pages are not initially page compressed, but they are after the REBUILD operation:



USE [tempdb];

-- DROP TABLE dbo.CompressedHeap;
CREATE TABLE dbo.CompressedHeap
(
ID INT IDENTITY(1, 1) NOT NULL,
String sysname,
[MaxLength] SMALLINT,
[Type] VARCHAR(5)
) WITH (DATA_COMPRESSION = PAGE);


INSERT INTO dbo.CompressedHeap ([String], [MaxLength], [Type])
SELECT col.[name], col.[max_length], obj.[type]
FROM master.sys.columns col
CROSS JOIN master.sys.objects obj;


SELECT [is_page_compressed], *
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED')
WHERE [is_iam_page] = 0
AND [is_allocated] = 1;
-- 394 pages


ALTER TABLE dbo.CompressedHeap REBUILD;


SELECT [is_page_compressed], *
FROM sys.dm_db_database_page_allocations(DB_ID(), OBJECT_ID(N'dbo.CompressedHeap'),
0, 1, 'DETAILED')
WHERE [is_iam_page] = 0
AND [is_allocated] = 1;
-- 179 pages






share|improve this answer














share|improve this answer



share|improve this answer








edited 23 hours ago

























answered yesterday









Solomon RutzkySolomon Rutzky

52.1k5 gold badges93 silver badges204 bronze badges




52.1k5 gold badges93 silver badges204 bronze badges











  • 1





    That is exactly what I need, thank you so much! I checked some of my actual tables and the ones loaded without the table lock have 0% of pages compressed while the new ones that I loaded with the table lock have 99.8% of the pages compressed (and far fewer of them), just as you describe.

    – Caitlin M. Shaw
    22 hours ago














  • 1





    That is exactly what I need, thank you so much! I checked some of my actual tables and the ones loaded without the table lock have 0% of pages compressed while the new ones that I loaded with the table lock have 99.8% of the pages compressed (and far fewer of them), just as you describe.

    – Caitlin M. Shaw
    22 hours ago








1




1





That is exactly what I need, thank you so much! I checked some of my actual tables and the ones loaded without the table lock have 0% of pages compressed while the new ones that I loaded with the table lock have 99.8% of the pages compressed (and far fewer of them), just as you describe.

– Caitlin M. Shaw
22 hours ago





That is exactly what I need, thank you so much! I checked some of my actual tables and the ones loaded without the table lock have 0% of pages compressed while the new ones that I loaded with the table lock have 99.8% of the pages compressed (and far fewer of them), just as you describe.

– Caitlin M. Shaw
22 hours ago













0














You can find the compression level in the sys.partitions dmv



SELECT t.name AS tablename,
i.name AS indexname,
p.data_compression_desc
FROM sys.tables AS t
INNER JOIN sys.indexes AS i
ON t.object_id = i.object_id
INNER JOIN sys.partitions AS p
ON i.object_id = p.object_id
AND i.index_id = p.index_id;





share|improve this answer





















  • 1





    Sadly, this is a scenario in which the actual compression on the data pages is not what's listed in sys.partitions.

    – Caitlin M. Shaw
    22 hours ago






  • 1





    Hi Bob (and @CaitlinM.Shaw ): the value in sys.partitions should be the requested / ideal data compression type. But since that value is just at the partition level, it can't show the per-page current value, nor the per-row current value, both of which can vary within each partition.

    – Solomon Rutzky
    14 hours ago
















0














You can find the compression level in the sys.partitions dmv



SELECT t.name AS tablename,
i.name AS indexname,
p.data_compression_desc
FROM sys.tables AS t
INNER JOIN sys.indexes AS i
ON t.object_id = i.object_id
INNER JOIN sys.partitions AS p
ON i.object_id = p.object_id
AND i.index_id = p.index_id;





share|improve this answer





















  • 1





    Sadly, this is a scenario in which the actual compression on the data pages is not what's listed in sys.partitions.

    – Caitlin M. Shaw
    22 hours ago






  • 1





    Hi Bob (and @CaitlinM.Shaw ): the value in sys.partitions should be the requested / ideal data compression type. But since that value is just at the partition level, it can't show the per-page current value, nor the per-row current value, both of which can vary within each partition.

    – Solomon Rutzky
    14 hours ago














0












0








0







You can find the compression level in the sys.partitions dmv



SELECT t.name AS tablename,
i.name AS indexname,
p.data_compression_desc
FROM sys.tables AS t
INNER JOIN sys.indexes AS i
ON t.object_id = i.object_id
INNER JOIN sys.partitions AS p
ON i.object_id = p.object_id
AND i.index_id = p.index_id;





share|improve this answer













You can find the compression level in the sys.partitions dmv



SELECT t.name AS tablename,
i.name AS indexname,
p.data_compression_desc
FROM sys.tables AS t
INNER JOIN sys.indexes AS i
ON t.object_id = i.object_id
INNER JOIN sys.partitions AS p
ON i.object_id = p.object_id
AND i.index_id = p.index_id;






share|improve this answer












share|improve this answer



share|improve this answer










answered 23 hours ago









Bob KlimesBob Klimes

2,26510 silver badges23 bronze badges




2,26510 silver badges23 bronze badges











  • 1





    Sadly, this is a scenario in which the actual compression on the data pages is not what's listed in sys.partitions.

    – Caitlin M. Shaw
    22 hours ago






  • 1





    Hi Bob (and @CaitlinM.Shaw ): the value in sys.partitions should be the requested / ideal data compression type. But since that value is just at the partition level, it can't show the per-page current value, nor the per-row current value, both of which can vary within each partition.

    – Solomon Rutzky
    14 hours ago














  • 1





    Sadly, this is a scenario in which the actual compression on the data pages is not what's listed in sys.partitions.

    – Caitlin M. Shaw
    22 hours ago






  • 1





    Hi Bob (and @CaitlinM.Shaw ): the value in sys.partitions should be the requested / ideal data compression type. But since that value is just at the partition level, it can't show the per-page current value, nor the per-row current value, both of which can vary within each partition.

    – Solomon Rutzky
    14 hours ago








1




1





Sadly, this is a scenario in which the actual compression on the data pages is not what's listed in sys.partitions.

– Caitlin M. Shaw
22 hours ago





Sadly, this is a scenario in which the actual compression on the data pages is not what's listed in sys.partitions.

– Caitlin M. Shaw
22 hours ago




1




1





Hi Bob (and @CaitlinM.Shaw ): the value in sys.partitions should be the requested / ideal data compression type. But since that value is just at the partition level, it can't show the per-page current value, nor the per-row current value, both of which can vary within each partition.

– Solomon Rutzky
14 hours ago





Hi Bob (and @CaitlinM.Shaw ): the value in sys.partitions should be the requested / ideal data compression type. But since that value is just at the partition level, it can't show the per-page current value, nor the per-row current value, both of which can vary within each partition.

– Solomon Rutzky
14 hours ago










Caitlin M. Shaw is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Caitlin M. Shaw is a new contributor. Be nice, and check out our Code of Conduct.













Caitlin M. Shaw is a new contributor. Be nice, and check out our Code of Conduct.












Caitlin M. Shaw is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Database Administrators Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f245254%2fhow-can-i-see-if-the-data-in-a-sql-server-table-is-page-compressed%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m