Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7563855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:46:15+00:00 2026-05-30T13:46:15+00:00

Existing table structure CREATE TABLE [MYTABLE]( [ROW1] [numeric](18, 0) NOT NULL, [ROW2] [numeric](18, 0)

  • 0

Existing table structure

CREATE TABLE [MYTABLE](
    [ROW1] [numeric](18, 0) NOT NULL,
    [ROW2] [numeric](18, 0) NOT NULL,
    [ROW3] [numeric](18, 0) NOT NULL,
    [ROW4] [numeric](18, 0) NULL,
    CONSTRAINT [MYTABLE_PK] PRIMARY KEY CLUSTERED ([ROW1] ASC, [ROW2] ASC, [ROW3] ASC)
)

This table has 2 non-clustered indexes, and the following stats:

RowCount:    5260744
Data Space:  229.609 MB
Index Space: 432.125 MB

I wanted to reduce the size of the indexes, and use a surrogate primary key as the clustered index, instead of the natural composite key.

New table structure

CREATE TABLE [dbo].[TEST_RUN_INFO](
    [ROW1] [numeric](18, 0) NOT NULL,
    [ROW2] [numeric](18, 0) NOT NULL,
    [ROW3] [numeric](18, 0) NOT NULL,
    [ROW4] [numeric](18, 0) NULL,
    [ID] [int] IDENTITY(1,1) NOT NULL,
    CONSTRAINT [MYTABLE_PK] PRIMARY KEY CLUSTERED ([ID] ASC)
)

Still with only 2 non-clustered indexes, here’s the new stats:

RowCount:    5260744
Data Space:  249.117 MB
Index Space: 470.867 MB

Question

Can someone account for how a clustered index using 3 NUMERIC(18,0) columns is smaller than a clustered index using a single INT column?

I rebuilt the indexes before and after the changes, and the fill factor is set to 0 for both structures.

The two non-clustered indexes are the same, and were not changed to include the new ID column.

sys.dm_db_index_physical_stats

Stats taken with the ID column

Composite clustered index

INDEX   TYPE            DEPTH   LEVEL   PAGECOUNT   RECORDCOUNT RECORDSIZE  
1       CLUSTERED       3       0       31884       5260744     47
1       CLUSTERED       3       1       143         31884       34
1       CLUSTERED       3       2       1           143         34
5       NONCLUSTERED    3       0       27404       5260744     40
5       NONCLUSTERED    3       1       167         27404       46
5       NONCLUSTERED    3       2       1           167         46
6       NONCLUSTERED    3       0       27400       5260744     40
6       NONCLUSTERED    3       1       164         27400       46
6       NONCLUSTERED    3       2       1           164         46

INT clustered index

INDEX   TYPE            DEPTH   LEVEL   PAGECOUNT   RECORDCOUNT RECORDSIZE  
1       CLUSTERED       3       0       31887       5260744     47
1       CLUSTERED       3       1       54          31887       11
1       CLUSTERED       3       2       1           54          11
5       NONCLUSTERED    4       0       29893       5260744     44
5       NONCLUSTERED    4       1       198         29893       50
5       NONCLUSTERED    4       2       3           198         50
5       NONCLUSTERED    4       3       1           3           50
6       NONCLUSTERED    4       0       29891       5260744     44
6       NONCLUSTERED    4       1       193         29891       50
6       NONCLUSTERED    4       2       2           193         50
6       NONCLUSTERED    4       3       1           2           50
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:46:16+00:00Added an answer on May 30, 2026 at 1:46 pm

    The clustered index leaf pages include all the columns of the table (not just the key columns). By adding a surrogate primary key you have just increased the length of all rows in the leaf pages by 4 bytes. Multiply that out by 5,260,744 rows and that equals an additional 20 MB to store the ID column.

    The key is narrower however so you may well have fewer non leaf level pages (use sys.dm_db_index_physical_stats to see this) and as the clustered index key is used as the row locator in the non clustered indexes this can make those smaller (but less covering) too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I create a unique constraint on an existing table in SQL Server
I need to add a NOT NULL column to an existing (populated) table that
If I have a table: CREATE TABLE Kids ( kid_id int(10) UNSIGNED NOT NULL
I need to create a dbf file which has the table structure of an
I haven't found a similar table structure in existing questions yet so I'm hoping
I have a tree structure in my database, eg for employees. create table employees
I have an existing table structure that looks something like this: AnimalTable ------------- |Id
I got an existing table in Oracle database how can I generate my Hibernate
I can link the results of an existing table/view to an Excel spreadsheet (by
I'm trying to add a foreign key to an existing table, and was having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.