Understanding the differences in the storage space used by two tablesIndexing - Uniqueidentifier Foreign Key or Intermediary mapping table?Why is Clustered Index on Primary Key compulsory?Parent-Child Tree Hierarchical ORDERUnable to drop non-PK index because it is referenced in a foreign key constraintdeteriorating stored procedure running timesSelect Into removes IDENTITY property from target tableWhy does imported txt table consume so much spaceMaximizing Availability on a Table When Changing Data TypeWhat is the most efficient way to store a bunch of empty fields, and ones with only a few choices?Identity Column in Concurrency, Multithreading, Parallel Processing
Is my plasma cannon concept viable?
Python program for fibonacci sequence using a recursive function
Need to read my home electrical Meter
What could a self-sustaining lunar colony slowly lose that would ultimately prove fatal?
First Program Tic-Tac-Toe
Why A=2 and B=1 in the call signs for Spirit and Opportunity?
How to keep consistency across the application architecture as a team grows?
Would Buddhists help non-Buddhists continuing their attachments?
Why does the Starter Set wizard have six spells in their spellbook?
Variable declaraton with extra in C
Did this character show any indication of wanting to rule before S8E6?
Co-author wants to put their current funding source in the acknowledgements section because they edited the paper
Are there any German nonsense poems (Jabberwocky)?
Is "vegetable base" a common term in English?
I want to know what marumaru means
What are nvme namespaces? How do they work?
Gravitational Force Between Numbers
Finding all files with a given extension whose base name is the name of the parent directory
What weight should be given to writers groups critiques?
The disk image is 497GB smaller than the target device
Why do Russians almost not use verbs of possession akin to "have"?
Why is this integration method not valid?
Dad jokes are fun
Count all vowels in string
Understanding the differences in the storage space used by two tables
Indexing - Uniqueidentifier Foreign Key or Intermediary mapping table?Why is Clustered Index on Primary Key compulsory?Parent-Child Tree Hierarchical ORDERUnable to drop non-PK index because it is referenced in a foreign key constraintdeteriorating stored procedure running timesSelect Into removes IDENTITY property from target tableWhy does imported txt table consume so much spaceMaximizing Availability on a Table When Changing Data TypeWhat is the most efficient way to store a bunch of empty fields, and ones with only a few choices?Identity Column in Concurrency, Multithreading, Parallel Processing
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have two tables in which, more or less, one contains a subset of data of the other one. There is some data I delete from the first table, which is inserted in the second one as historical data.
These are the defintions:
CREATE TABLE [dbo].[CIC_DESLUNGHE](
[CD_CIC_DESLUNGHE] [bigint] IDENTITY(1,1) NOT NULL,
[CD_CIC_PRODUZIONE] [bigint] NOT NULL,
[CD_CIC_OPERAZIONI] [bigint] NOT NULL,
[AFNMPROG] [int] NOT NULL,
[AFDSLINE] [nvarchar](max) NULL,
CONSTRAINT [PK_CIC_DESLUNGHE] PRIMARY KEY CLUSTERED
(
[CD_CIC_DESLUNGHE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 99) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[CIC_DESLUNGHE_STORICI](
[CD_CIC_DESLUNGHE_STORICI] [bigint] IDENTITY(1,1) NOT NULL,
[CD_CIC_PRODUZIONE_STORICI] [bigint] NOT NULL,
[CD_CIC_OPERAZIONI_STORICI] [bigint] NOT NULL,
[AFNMPROG] [int] NOT NULL,
[AFDSLINE] [nvarchar](max) NOT NULL,
CONSTRAINT [PK_CIC_DESLUNGHE_STORICI_1] PRIMARY KEY CLUSTERED
(
[CD_CIC_DESLUNGHE_STORICI] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
The second table contains a subset of data that I need it as historicization of my data.
Table Rows TotalSpace MB
--------------------- ---------- -------------
CIC_DESLUNGHE_STORICI 12.709.497 48214,75
CIC_DESLUNGHE 24.827.337 5675,49
What leaves me astonished is that the total storage space utilized. The subset table use 10 times the space of the other.
Any idea why this is happening?
I tried rebuilding the clustered index of CIC_DESLUNGHE_STORICI
, but the storage only dropped from 48 GB to 47 GB.
-- EDIT --
This is the result I got with the query of Josh Darnell
sql-server sql-server-2016 storage
New contributor
add a comment |
I have two tables in which, more or less, one contains a subset of data of the other one. There is some data I delete from the first table, which is inserted in the second one as historical data.
These are the defintions:
CREATE TABLE [dbo].[CIC_DESLUNGHE](
[CD_CIC_DESLUNGHE] [bigint] IDENTITY(1,1) NOT NULL,
[CD_CIC_PRODUZIONE] [bigint] NOT NULL,
[CD_CIC_OPERAZIONI] [bigint] NOT NULL,
[AFNMPROG] [int] NOT NULL,
[AFDSLINE] [nvarchar](max) NULL,
CONSTRAINT [PK_CIC_DESLUNGHE] PRIMARY KEY CLUSTERED
(
[CD_CIC_DESLUNGHE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 99) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[CIC_DESLUNGHE_STORICI](
[CD_CIC_DESLUNGHE_STORICI] [bigint] IDENTITY(1,1) NOT NULL,
[CD_CIC_PRODUZIONE_STORICI] [bigint] NOT NULL,
[CD_CIC_OPERAZIONI_STORICI] [bigint] NOT NULL,
[AFNMPROG] [int] NOT NULL,
[AFDSLINE] [nvarchar](max) NOT NULL,
CONSTRAINT [PK_CIC_DESLUNGHE_STORICI_1] PRIMARY KEY CLUSTERED
(
[CD_CIC_DESLUNGHE_STORICI] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
The second table contains a subset of data that I need it as historicization of my data.
Table Rows TotalSpace MB
--------------------- ---------- -------------
CIC_DESLUNGHE_STORICI 12.709.497 48214,75
CIC_DESLUNGHE 24.827.337 5675,49
What leaves me astonished is that the total storage space utilized. The subset table use 10 times the space of the other.
Any idea why this is happening?
I tried rebuilding the clustered index of CIC_DESLUNGHE_STORICI
, but the storage only dropped from 48 GB to 47 GB.
-- EDIT --
This is the result I got with the query of Josh Darnell
sql-server sql-server-2016 storage
New contributor
add a comment |
I have two tables in which, more or less, one contains a subset of data of the other one. There is some data I delete from the first table, which is inserted in the second one as historical data.
These are the defintions:
CREATE TABLE [dbo].[CIC_DESLUNGHE](
[CD_CIC_DESLUNGHE] [bigint] IDENTITY(1,1) NOT NULL,
[CD_CIC_PRODUZIONE] [bigint] NOT NULL,
[CD_CIC_OPERAZIONI] [bigint] NOT NULL,
[AFNMPROG] [int] NOT NULL,
[AFDSLINE] [nvarchar](max) NULL,
CONSTRAINT [PK_CIC_DESLUNGHE] PRIMARY KEY CLUSTERED
(
[CD_CIC_DESLUNGHE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 99) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[CIC_DESLUNGHE_STORICI](
[CD_CIC_DESLUNGHE_STORICI] [bigint] IDENTITY(1,1) NOT NULL,
[CD_CIC_PRODUZIONE_STORICI] [bigint] NOT NULL,
[CD_CIC_OPERAZIONI_STORICI] [bigint] NOT NULL,
[AFNMPROG] [int] NOT NULL,
[AFDSLINE] [nvarchar](max) NOT NULL,
CONSTRAINT [PK_CIC_DESLUNGHE_STORICI_1] PRIMARY KEY CLUSTERED
(
[CD_CIC_DESLUNGHE_STORICI] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
The second table contains a subset of data that I need it as historicization of my data.
Table Rows TotalSpace MB
--------------------- ---------- -------------
CIC_DESLUNGHE_STORICI 12.709.497 48214,75
CIC_DESLUNGHE 24.827.337 5675,49
What leaves me astonished is that the total storage space utilized. The subset table use 10 times the space of the other.
Any idea why this is happening?
I tried rebuilding the clustered index of CIC_DESLUNGHE_STORICI
, but the storage only dropped from 48 GB to 47 GB.
-- EDIT --
This is the result I got with the query of Josh Darnell
sql-server sql-server-2016 storage
New contributor
I have two tables in which, more or less, one contains a subset of data of the other one. There is some data I delete from the first table, which is inserted in the second one as historical data.
These are the defintions:
CREATE TABLE [dbo].[CIC_DESLUNGHE](
[CD_CIC_DESLUNGHE] [bigint] IDENTITY(1,1) NOT NULL,
[CD_CIC_PRODUZIONE] [bigint] NOT NULL,
[CD_CIC_OPERAZIONI] [bigint] NOT NULL,
[AFNMPROG] [int] NOT NULL,
[AFDSLINE] [nvarchar](max) NULL,
CONSTRAINT [PK_CIC_DESLUNGHE] PRIMARY KEY CLUSTERED
(
[CD_CIC_DESLUNGHE] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 99) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[CIC_DESLUNGHE_STORICI](
[CD_CIC_DESLUNGHE_STORICI] [bigint] IDENTITY(1,1) NOT NULL,
[CD_CIC_PRODUZIONE_STORICI] [bigint] NOT NULL,
[CD_CIC_OPERAZIONI_STORICI] [bigint] NOT NULL,
[AFNMPROG] [int] NOT NULL,
[AFDSLINE] [nvarchar](max) NOT NULL,
CONSTRAINT [PK_CIC_DESLUNGHE_STORICI_1] PRIMARY KEY CLUSTERED
(
[CD_CIC_DESLUNGHE_STORICI] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
The second table contains a subset of data that I need it as historicization of my data.
Table Rows TotalSpace MB
--------------------- ---------- -------------
CIC_DESLUNGHE_STORICI 12.709.497 48214,75
CIC_DESLUNGHE 24.827.337 5675,49
What leaves me astonished is that the total storage space utilized. The subset table use 10 times the space of the other.
Any idea why this is happening?
I tried rebuilding the clustered index of CIC_DESLUNGHE_STORICI
, but the storage only dropped from 48 GB to 47 GB.
-- EDIT --
This is the result I got with the query of Josh Darnell
sql-server sql-server-2016 storage
sql-server sql-server-2016 storage
New contributor
New contributor
edited May 17 at 7:53
Galma88
New contributor
asked May 16 at 14:56
Galma88Galma88
1136
1136
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Based on the information given, one explanation is that the size of the data being stored in the nvarchar(max)
column used to be much larger than it is now.
- ~12 million historical rows averaging 3.88 KB per row
- ~24 million live rows averaging 0.23 KB per row
You can double check this by using the dynamic management function sys.dm_db_index_physical_stats on each of the two tables, specifically looking at the "avg_record_size_in_bytes" column. Something like this:
SELECT
DB_NAME(ips.database_id),
OBJECT_NAME(ips.[object_id]),
ips.index_id,
ips.index_type_desc,
ips.index_level,
ips.alloc_unit_type_desc,
ips.page_count,
ips.record_count,
ips.min_record_size_in_bytes,
ips.max_record_size_in_bytes,
ips.avg_record_size_in_bytes
FROM sys.dm_db_index_physical_stats
(
DB_ID(N'YourDatabaseName'),
OBJECT_ID(N'CIC_DESLUNGHE'),
NULL,
NULL ,
'DETAILED'
) ips;
And
SELECT
DB_NAME(ips.database_id),
OBJECT_NAME(ips.[object_id]),
ips.index_id,
ips.index_type_desc,
ips.index_level,
ips.alloc_unit_type_desc,
ips.page_count,
ips.record_count,
ips.min_record_size_in_bytes,
ips.max_record_size_in_bytes,
ips.avg_record_size_in_bytes
FROM sys.dm_db_index_physical_stats
(
DB_ID(N'YourDatabaseName'),
OBJECT_ID(N'CIC_DESLUNGHE_STORICI'),
NULL,
NULL ,
'DETAILED'
) ips;
Compare the results of the two queries and see if there are any surprising discrepancies.
I left other filters off the function call because this will also show nonclustered indexes. You didn't mention how you arrived at the numbers in your question, but if they include NC indexes on the tables, perhaps those are contributing to the size difference.
I edited my question with the results of the execution of your query. What I can see is a big difference in the first row where there's a avg value higher than in the first table
– Galma88
May 17 at 7:54
1
@Galma88 That confirms my theory. You have older data in the history table, and both the number of LOB_DATA rows, and the avg size of rows in the clustered index, is higher. This means your more recent rows, in the live table, have less data into the[AFDSLINE]
column. Maybe the application has been changed to put less data there.
– Josh Darnell
May 17 at 11:31
add a comment |
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
);
);
Galma88 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f238331%2funderstanding-the-differences-in-the-storage-space-used-by-two-tables%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Based on the information given, one explanation is that the size of the data being stored in the nvarchar(max)
column used to be much larger than it is now.
- ~12 million historical rows averaging 3.88 KB per row
- ~24 million live rows averaging 0.23 KB per row
You can double check this by using the dynamic management function sys.dm_db_index_physical_stats on each of the two tables, specifically looking at the "avg_record_size_in_bytes" column. Something like this:
SELECT
DB_NAME(ips.database_id),
OBJECT_NAME(ips.[object_id]),
ips.index_id,
ips.index_type_desc,
ips.index_level,
ips.alloc_unit_type_desc,
ips.page_count,
ips.record_count,
ips.min_record_size_in_bytes,
ips.max_record_size_in_bytes,
ips.avg_record_size_in_bytes
FROM sys.dm_db_index_physical_stats
(
DB_ID(N'YourDatabaseName'),
OBJECT_ID(N'CIC_DESLUNGHE'),
NULL,
NULL ,
'DETAILED'
) ips;
And
SELECT
DB_NAME(ips.database_id),
OBJECT_NAME(ips.[object_id]),
ips.index_id,
ips.index_type_desc,
ips.index_level,
ips.alloc_unit_type_desc,
ips.page_count,
ips.record_count,
ips.min_record_size_in_bytes,
ips.max_record_size_in_bytes,
ips.avg_record_size_in_bytes
FROM sys.dm_db_index_physical_stats
(
DB_ID(N'YourDatabaseName'),
OBJECT_ID(N'CIC_DESLUNGHE_STORICI'),
NULL,
NULL ,
'DETAILED'
) ips;
Compare the results of the two queries and see if there are any surprising discrepancies.
I left other filters off the function call because this will also show nonclustered indexes. You didn't mention how you arrived at the numbers in your question, but if they include NC indexes on the tables, perhaps those are contributing to the size difference.
I edited my question with the results of the execution of your query. What I can see is a big difference in the first row where there's a avg value higher than in the first table
– Galma88
May 17 at 7:54
1
@Galma88 That confirms my theory. You have older data in the history table, and both the number of LOB_DATA rows, and the avg size of rows in the clustered index, is higher. This means your more recent rows, in the live table, have less data into the[AFDSLINE]
column. Maybe the application has been changed to put less data there.
– Josh Darnell
May 17 at 11:31
add a comment |
Based on the information given, one explanation is that the size of the data being stored in the nvarchar(max)
column used to be much larger than it is now.
- ~12 million historical rows averaging 3.88 KB per row
- ~24 million live rows averaging 0.23 KB per row
You can double check this by using the dynamic management function sys.dm_db_index_physical_stats on each of the two tables, specifically looking at the "avg_record_size_in_bytes" column. Something like this:
SELECT
DB_NAME(ips.database_id),
OBJECT_NAME(ips.[object_id]),
ips.index_id,
ips.index_type_desc,
ips.index_level,
ips.alloc_unit_type_desc,
ips.page_count,
ips.record_count,
ips.min_record_size_in_bytes,
ips.max_record_size_in_bytes,
ips.avg_record_size_in_bytes
FROM sys.dm_db_index_physical_stats
(
DB_ID(N'YourDatabaseName'),
OBJECT_ID(N'CIC_DESLUNGHE'),
NULL,
NULL ,
'DETAILED'
) ips;
And
SELECT
DB_NAME(ips.database_id),
OBJECT_NAME(ips.[object_id]),
ips.index_id,
ips.index_type_desc,
ips.index_level,
ips.alloc_unit_type_desc,
ips.page_count,
ips.record_count,
ips.min_record_size_in_bytes,
ips.max_record_size_in_bytes,
ips.avg_record_size_in_bytes
FROM sys.dm_db_index_physical_stats
(
DB_ID(N'YourDatabaseName'),
OBJECT_ID(N'CIC_DESLUNGHE_STORICI'),
NULL,
NULL ,
'DETAILED'
) ips;
Compare the results of the two queries and see if there are any surprising discrepancies.
I left other filters off the function call because this will also show nonclustered indexes. You didn't mention how you arrived at the numbers in your question, but if they include NC indexes on the tables, perhaps those are contributing to the size difference.
I edited my question with the results of the execution of your query. What I can see is a big difference in the first row where there's a avg value higher than in the first table
– Galma88
May 17 at 7:54
1
@Galma88 That confirms my theory. You have older data in the history table, and both the number of LOB_DATA rows, and the avg size of rows in the clustered index, is higher. This means your more recent rows, in the live table, have less data into the[AFDSLINE]
column. Maybe the application has been changed to put less data there.
– Josh Darnell
May 17 at 11:31
add a comment |
Based on the information given, one explanation is that the size of the data being stored in the nvarchar(max)
column used to be much larger than it is now.
- ~12 million historical rows averaging 3.88 KB per row
- ~24 million live rows averaging 0.23 KB per row
You can double check this by using the dynamic management function sys.dm_db_index_physical_stats on each of the two tables, specifically looking at the "avg_record_size_in_bytes" column. Something like this:
SELECT
DB_NAME(ips.database_id),
OBJECT_NAME(ips.[object_id]),
ips.index_id,
ips.index_type_desc,
ips.index_level,
ips.alloc_unit_type_desc,
ips.page_count,
ips.record_count,
ips.min_record_size_in_bytes,
ips.max_record_size_in_bytes,
ips.avg_record_size_in_bytes
FROM sys.dm_db_index_physical_stats
(
DB_ID(N'YourDatabaseName'),
OBJECT_ID(N'CIC_DESLUNGHE'),
NULL,
NULL ,
'DETAILED'
) ips;
And
SELECT
DB_NAME(ips.database_id),
OBJECT_NAME(ips.[object_id]),
ips.index_id,
ips.index_type_desc,
ips.index_level,
ips.alloc_unit_type_desc,
ips.page_count,
ips.record_count,
ips.min_record_size_in_bytes,
ips.max_record_size_in_bytes,
ips.avg_record_size_in_bytes
FROM sys.dm_db_index_physical_stats
(
DB_ID(N'YourDatabaseName'),
OBJECT_ID(N'CIC_DESLUNGHE_STORICI'),
NULL,
NULL ,
'DETAILED'
) ips;
Compare the results of the two queries and see if there are any surprising discrepancies.
I left other filters off the function call because this will also show nonclustered indexes. You didn't mention how you arrived at the numbers in your question, but if they include NC indexes on the tables, perhaps those are contributing to the size difference.
Based on the information given, one explanation is that the size of the data being stored in the nvarchar(max)
column used to be much larger than it is now.
- ~12 million historical rows averaging 3.88 KB per row
- ~24 million live rows averaging 0.23 KB per row
You can double check this by using the dynamic management function sys.dm_db_index_physical_stats on each of the two tables, specifically looking at the "avg_record_size_in_bytes" column. Something like this:
SELECT
DB_NAME(ips.database_id),
OBJECT_NAME(ips.[object_id]),
ips.index_id,
ips.index_type_desc,
ips.index_level,
ips.alloc_unit_type_desc,
ips.page_count,
ips.record_count,
ips.min_record_size_in_bytes,
ips.max_record_size_in_bytes,
ips.avg_record_size_in_bytes
FROM sys.dm_db_index_physical_stats
(
DB_ID(N'YourDatabaseName'),
OBJECT_ID(N'CIC_DESLUNGHE'),
NULL,
NULL ,
'DETAILED'
) ips;
And
SELECT
DB_NAME(ips.database_id),
OBJECT_NAME(ips.[object_id]),
ips.index_id,
ips.index_type_desc,
ips.index_level,
ips.alloc_unit_type_desc,
ips.page_count,
ips.record_count,
ips.min_record_size_in_bytes,
ips.max_record_size_in_bytes,
ips.avg_record_size_in_bytes
FROM sys.dm_db_index_physical_stats
(
DB_ID(N'YourDatabaseName'),
OBJECT_ID(N'CIC_DESLUNGHE_STORICI'),
NULL,
NULL ,
'DETAILED'
) ips;
Compare the results of the two queries and see if there are any surprising discrepancies.
I left other filters off the function call because this will also show nonclustered indexes. You didn't mention how you arrived at the numbers in your question, but if they include NC indexes on the tables, perhaps those are contributing to the size difference.
edited May 16 at 16:08
answered May 16 at 16:03
Josh DarnellJosh Darnell
9,20232345
9,20232345
I edited my question with the results of the execution of your query. What I can see is a big difference in the first row where there's a avg value higher than in the first table
– Galma88
May 17 at 7:54
1
@Galma88 That confirms my theory. You have older data in the history table, and both the number of LOB_DATA rows, and the avg size of rows in the clustered index, is higher. This means your more recent rows, in the live table, have less data into the[AFDSLINE]
column. Maybe the application has been changed to put less data there.
– Josh Darnell
May 17 at 11:31
add a comment |
I edited my question with the results of the execution of your query. What I can see is a big difference in the first row where there's a avg value higher than in the first table
– Galma88
May 17 at 7:54
1
@Galma88 That confirms my theory. You have older data in the history table, and both the number of LOB_DATA rows, and the avg size of rows in the clustered index, is higher. This means your more recent rows, in the live table, have less data into the[AFDSLINE]
column. Maybe the application has been changed to put less data there.
– Josh Darnell
May 17 at 11:31
I edited my question with the results of the execution of your query. What I can see is a big difference in the first row where there's a avg value higher than in the first table
– Galma88
May 17 at 7:54
I edited my question with the results of the execution of your query. What I can see is a big difference in the first row where there's a avg value higher than in the first table
– Galma88
May 17 at 7:54
1
1
@Galma88 That confirms my theory. You have older data in the history table, and both the number of LOB_DATA rows, and the avg size of rows in the clustered index, is higher. This means your more recent rows, in the live table, have less data into the
[AFDSLINE]
column. Maybe the application has been changed to put less data there.– Josh Darnell
May 17 at 11:31
@Galma88 That confirms my theory. You have older data in the history table, and both the number of LOB_DATA rows, and the avg size of rows in the clustered index, is higher. This means your more recent rows, in the live table, have less data into the
[AFDSLINE]
column. Maybe the application has been changed to put less data there.– Josh Darnell
May 17 at 11:31
add a comment |
Galma88 is a new contributor. Be nice, and check out our Code of Conduct.
Galma88 is a new contributor. Be nice, and check out our Code of Conduct.
Galma88 is a new contributor. Be nice, and check out our Code of Conduct.
Galma88 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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f238331%2funderstanding-the-differences-in-the-storage-space-used-by-two-tables%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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