Showing posts with label space. Show all posts
Showing posts with label space. Show all posts

Monday, March 19, 2012

Collapsing columns in table mode, part II

I figured out how to collapse a column, but the report generator is maintaining the space that the collapsed columns occupied even when the columns are hidden. For me, it's valuable for space optimization to have all remaining columns to the right "move over" to be flush against the other visible columns. Can this be done?Is this possible?|||

What you explain as your goal is the behavior I see in RS 2005. If I assign a Toggle Item to a table column, columns to the right of it move left when the column is hidden.

Are you sure you're assigning the Toggle Item to the Table Column instead of the individual table cells within the column?

-Chris

|||Hi Chris, thanks for hte response. I tried what you suggest, and that is select an entire column and assign a textbox to control the visibility, but whenever I did that, I get the following error:

"The definition of the report '/ForecastReport' is invalid. The table 'table1' has 'textbox37' as a toggle item. Toggle items must be text boxes that share the same scope as the hidden item or are in a scope that contains the hidden item, and caonnot be contained within the current report item unless current grouping scope has a Parent"

One interesting thing about this error that I just noticed is, in the report designer, I have tripled checked to make sure I've got the desired COLUMN selected, not 'table1'.|||Perhaps more telling, when I select an entire column in the designer and then go to the "visibility" section, the "ToggleItem" drop down is completely empty of available choices.|||

Did you ever found a solution to this. I do have the same problem.

yours sincerely
Johan

Collapsing columns in table mode, part II

I figured out how to collapse a column, but the report generator is maintaining the space that the collapsed columns occupied even when the columns are hidden. For me, it's valuable for space optimization to have all remaining columns to the right "move over" to be flush against the other visible columns. Can this be done?Is this possible?|||

What you explain as your goal is the behavior I see in RS 2005. If I assign a Toggle Item to a table column, columns to the right of it move left when the column is hidden.

Are you sure you're assigning the Toggle Item to the Table Column instead of the individual table cells within the column?

-Chris

|||Hi Chris, thanks for hte response. I tried what you suggest, and that is select an entire column and assign a textbox to control the visibility, but whenever I did that, I get the following error:

"The definition of the report '/ForecastReport' is invalid. The table 'table1' has 'textbox37' as a toggle item. Toggle items must be text boxes that share the same scope as the hidden item or are in a scope that contains the hidden item, and caonnot be contained within the current report item unless current grouping scope has a Parent"

One interesting thing about this error that I just noticed is, in the report designer, I have tripled checked to make sure I've got the desired COLUMN selected, not 'table1'.|||Perhaps more telling, when I select an entire column in the designer and then go to the "visibility" section, the "ToggleItem" drop down is completely empty of available choices.|||

Did you ever found a solution to this. I do have the same problem.

yours sincerely
Johan

Friday, February 10, 2012

Clustered index and file space question

I have been doing testing on tables sizes and I ran into a
situation that I do not understand.
My default fill factor is set to 95%.
I used a SELECT INTO to copy a fact table for testing.
The table was about 1.1 GB in size.
I then created a primary key /clustered index on an
integer value on the new table.
The table grew to about 1.9 GB in size.
I then truncated this table but left the index on it.
I then ran an INSERT INTO statement to copy the origianl
fact table.
The table was 1.1 GB in size and contained the clustered
index.
Why would creating a clustered index increase a table's
size when inserting into a table with an existing
clustered index had no significant size difference?
Doesn't the clustered index actually contain the data
pages and therefore shouldn't affect the size of the table?
Thanks,
Jonathan Lacefield
MCDBAThis is a multi-part message in MIME format.
--=_NextPart_000_01F7_01C376C4.E95D4FA0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
When you create or rebuild a clustered index, SQL Server requires 1.2 X =the size of the table in free space in order to do the sort.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Jonathan Lacefield" <Jonathan.lacefield@.solutionbuilders.com> wrote in =message news:002c01c376e5$98532500$a301280a@.phx.gbl...
I have been doing testing on tables sizes and I ran into a situation that I do not understand.
My default fill factor is set to 95%.
I used a SELECT INTO to copy a fact table for testing. The table was about 1.1 GB in size.
I then created a primary key /clustered index on an integer value on the new table. The table grew to about 1.9 GB in size.
I then truncated this table but left the index on it. I then ran an INSERT INTO statement to copy the origianl fact table.
The table was 1.1 GB in size and contained the clustered index.
Why would creating a clustered index increase a table's size when inserting into a table with an existing clustered index had no significant size difference? Doesn't the clustered index actually contain the data pages and therefore shouldn't affect the size of the table?
Thanks,
Jonathan Lacefield
MCDBA
--=_NextPart_000_01F7_01C376C4.E95D4FA0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

When you create or rebuild a clustered =index, SQL Server requires 1.2 X the size of the table in free space in order to do =the sort.
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"Jonathan Lacefield" wrote in message news:002c01c376e5$98=532500$a301280a@.phx.gbl...I have been doing testing on tables sizes and I ran into a situation =that I do not understand.My default fill factor is set to 95%.I =used a SELECT INTO to copy a fact table for testing. The table was =about 1.1 GB in size.I then created a primary key /clustered index on an integer value on the new table. The table grew to about =1.9 GB in size.I then truncated this table but left the index on it. =I then ran an INSERT INTO statement to copy the origianl fact =table.The table was 1.1 GB in size and contained the clustered =index.Why would creating a clustered index increase a table's size when inserting =into a table with an existing clustered index had no significant size difference? Doesn't the clustered index actually contain the =data pages and therefore shouldn't affect the size of the table?Thanks,Jonathan LacefieldMCDBA

--=_NextPart_000_01F7_01C376C4.E95D4FA0--|||This is a multi-part message in MIME format.
--=_NextPart_000_0025_01C37769.7486AB40
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Tibor, I don't believe that the space is released after the rebuild. =Let's say you had a single-file filegroups with only one 100MB, =non-indexed table in it. If you created a clustered index on it, I'd =expect the file to be about 220MB when completed. This happens to me =when I rebuild large tables. I see it in my file growth and the free =space available in the file.
-- Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
.
"Tibor Karaszi" =<tibor.please_reply_to_public_forum.karaszi@.cornerstone.se> wrote in =message news:%23G$gqX4dDHA.2804@.TK2MSFTNGP11.phx.gbl...
... but that should be released after the rebuild is done. The question =is, I guess, how Jonathan checked the space used (file or table level)? =If at table level, how was that done (sysindexes was up-to-date or not)? =Also, assuming that able level and correct info, what did DBCC =SHOWCONTIG say (avg page density)?
-- Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=3Ddjq&as =ugroup=3Dmicrosoft.public.sqlserver
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:uw9AgZudDHA.3464@.TK2MSFTNGP11.phx.gbl...
When you create or rebuild a clustered index, SQL Server requires 1.2 =X the size of the table in free space in order to do the sort.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Jonathan Lacefield" <Jonathan.lacefield@.solutionbuilders.com> wrote =in message news:002c01c376e5$98532500$a301280a@.phx.gbl...
I have been doing testing on tables sizes and I ran into a situation that I do not understand.
My default fill factor is set to 95%.
I used a SELECT INTO to copy a fact table for testing. The table was about 1.1 GB in size.
I then created a primary key /clustered index on an integer value on the new table. The table grew to about 1.9 GB in size.
I then truncated this table but left the index on it. I then ran an INSERT INTO statement to copy the origianl fact table.
The table was 1.1 GB in size and contained the clustered index.
Why would creating a clustered index increase a table's size when inserting into a table with an existing clustered index had no significant size difference? Doesn't the clustered index actually contain the data pages and therefore shouldn't affect the size of the table?
Thanks,
Jonathan Lacefield
MCDBA
--=_NextPart_000_0025_01C37769.7486AB40
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Tibor, I don't believe that the space =is released after the rebuild. Let's say you had a single-file filegroups with =only one 100MB, non-indexed table in it. If you created a clustered =index on it, I'd expect the file to be about 220MB when completed. This =happens to me when I rebuild large tables. I see it in my file growth and the =free space available in the file.
-- Tom
----Thomas A. =Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql.
"Tibor Karaszi" wrote in message news:%23G$gqX4dDHA.=2804@.TK2MSFTNGP11.phx.gbl...
... but that should be released after =the rebuild is done. The question is, I guess, how Jonathan checked the space used =(file or table level)? If at table level, how was that done (sysindexes was =up-to-date or not)? Also, assuming that able level and correct info, what did DBCC =SHOWCONTIG say (avg page density)?
-- Tibor Karaszi, SQL Server MVPArchive at: http://groups.google.com/groups?oi=3Ddjq&as">http://groups.go=ogle.com/groups?oi=3Ddjq&as ugroup=3Dmicrosoft.public.sqlserver
"Tom Moreau" = wrote in message news:uw9AgZudDHA.3464=@.TK2MSFTNGP11.phx.gbl...
When you create or rebuild a =clustered index, SQL Server requires 1.2 X the size of the table in free space in order =to do the sort.
-- Tom

=---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql


"Jonathan Lacefield" wrote in message news:002c01c376e5$98=532500$a301280a@.phx.gbl...I have been doing testing on tables sizes and I ran into a situation =that I do not understand.My default fill factor is set to =95%.I used a SELECT INTO to copy a fact table for testing. The table =was about 1.1 GB in size.I then created a primary key /clustered index =on an integer value on the new table. The table grew to about =1.9 GB in size.I then truncated this table but left the index on =it. I then ran an INSERT INTO statement to copy the origianl fact table.The table was 1.1 GB in size and contained the clustered index.Why would creating a clustered index increase a =table's size when inserting into a table with an existing clustered =index had no significant size difference? Doesn't the clustered index =actually contain the data pages and therefore shouldn't affect the size of =the table?Thanks,Jonathan LacefieldMCDBA

--=_NextPart_000_0025_01C37769.7486AB40--|||This is a multi-part message in MIME format.
--=_NextPart_000_024D_01C3779C.3FF57400
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Tom,
I was referring to the space *in* the database file (the "table size"). =Like a copy operation of a file. After you copied the file, the sectors =that the "old" file occupied are available for re-use. I agree that the =database file does not shrink in size after the create/rebuild.
-- Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=3Ddjq&as =ugroup=3Dmicrosoft.public.sqlserver
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:eiYE$r4dDHA.560@.tk2msftngp13.phx.gbl...
Tibor, I don't believe that the space is released after the rebuild. =Let's say you had a single-file filegroups with only one 100MB, =non-indexed table in it. If you created a clustered index on it, I'd =expect the file to be about 220MB when completed. This happens to me =when I rebuild large tables. I see it in my file growth and the free =space available in the file.
-- Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
.
"Tibor Karaszi" =<tibor.please_reply_to_public_forum.karaszi@.cornerstone.se> wrote in =message news:%23G$gqX4dDHA.2804@.TK2MSFTNGP11.phx.gbl...
... but that should be released after the rebuild is done. The =question is, I guess, how Jonathan checked the space used (file or table =level)? If at table level, how was that done (sysindexes was up-to-date =or not)? Also, assuming that able level and correct info, what did DBCC =SHOWCONTIG say (avg page density)?
-- Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=3Ddjq&as =ugroup=3Dmicrosoft.public.sqlserver
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:uw9AgZudDHA.3464@.TK2MSFTNGP11.phx.gbl...
When you create or rebuild a clustered index, SQL Server requires =1.2 X the size of the table in free space in order to do the sort.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Jonathan Lacefield" <Jonathan.lacefield@.solutionbuilders.com> wrote =in message news:002c01c376e5$98532500$a301280a@.phx.gbl...
I have been doing testing on tables sizes and I ran into a situation that I do not understand.
My default fill factor is set to 95%.
I used a SELECT INTO to copy a fact table for testing. The table was about 1.1 GB in size.
I then created a primary key /clustered index on an integer value on the new table. The table grew to about 1.9 GB in size.
I then truncated this table but left the index on it. I then ran an INSERT INTO statement to copy the origianl fact table.
The table was 1.1 GB in size and contained the clustered index.
Why would creating a clustered index increase a table's size when inserting into a table with an existing clustered index had no significant size difference? Doesn't the clustered index actually contain the data pages and therefore shouldn't affect the size of the table?
Thanks,
Jonathan Lacefield
MCDBA
--=_NextPart_000_024D_01C3779C.3FF57400
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Tom,
I was referring to the space *in* the =database file (the "table size"). Like a copy operation of a file. After you copied =the file, the sectors that the "old" file occupied are available for re-use. I =agree that the database file does not shrink in size after the =create/rebuild.
-- Tibor Karaszi, SQL Server MVPArchive at: http://groups.google.com/groups?oi=3Ddjq&as">http://groups.go=ogle.com/groups?oi=3Ddjq&as ugroup=3Dmicrosoft.public.sqlserver
"Tom Moreau" = wrote in message news:eiYE$r4dDHA.560@.t=k2msftngp13.phx.gbl...
Tibor, I don't believe that the =space is released after the rebuild. Let's say you had a single-file =filegroups with only one 100MB, non-indexed table in it. If you created a =clustered index on it, I'd expect the file to be about 220MB when =completed. This happens to me when I rebuild large tables. I see it in my file =growth and the free space available in the file.
-- Tom

----Thomas A. =Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql.
"Tibor Karaszi" wrote in message news:%23G$gqX4dDHA.=2804@.TK2MSFTNGP11.phx.gbl...
... but that should be released after =the rebuild is done. The question is, I guess, how Jonathan checked the space used =(file or table level)? If at table level, how was that done (sysindexes was up-to-date or not)? Also, assuming that able level and correct info, =what did DBCC SHOWCONTIG say (avg page density)?
-- Tibor Karaszi, SQL Server MVPArchive at: http://groups.google.com/groups?oi=3Ddjq&as">http://groups.go=ogle.com/groups?oi=3Ddjq&as ugroup=3Dmicrosoft.public.sqlserver


"Tom Moreau" = wrote in message news:uw9AgZudDHA.3464=@.TK2MSFTNGP11.phx.gbl...
When you create or rebuild a =clustered index, SQL Server requires 1.2 X the size of the table in free space in =order to do the sort.
-- Tom

=---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql


"Jonathan Lacefield" wrote in message news:002c01c376e5$98=532500$a301280a@.phx.gbl...I have been doing testing on tables sizes and I ran into a =situation that I do not understand.My default fill factor is set to =95%.I used a SELECT INTO to copy a fact table for testing. The =table was about 1.1 GB in size.I then created a primary key /clustered =index on an integer value on the new table. The table grew =to about 1.9 GB in size.I then truncated this table but left the =index on it. I then ran an INSERT INTO statement to copy the =origianl fact table.The table was 1.1 GB in size and contained the =clustered index.Why would creating a clustered index increase a =table's size when inserting into a table with an existing clustered =index had no significant size difference? Doesn't the clustered =index actually contain the data pages and therefore shouldn't affect =the size of the table?Thanks,Jonathan LacefieldMCDBA

--=_NextPart_000_024D_01C3779C.3FF57400--|||This is a multi-part message in MIME format.
--=_NextPart_000_0023_01C37776.32723E60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
OK, perhaps he should run DBCC UPDATEUSAGE (or sp_spaceused MyTable, =true) and see if that gives him the right numbers.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Tibor Karaszi" =<tibor.please_reply_to_public_forum.karaszi@.cornerstone.se> wrote in =message news:O2YRAu4dDHA.568@.TK2MSFTNGP11.phx.gbl...
Tom,
I was referring to the space *in* the database file (the "table size"). =Like a copy operation of a file. After you copied the file, the sectors =that the "old" file occupied are available for re-use. I agree that the =database file does not shrink in size after the create/rebuild.
-- Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=3Ddjq&as =ugroup=3Dmicrosoft.public.sqlserver
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:eiYE$r4dDHA.560@.tk2msftngp13.phx.gbl...
Tibor, I don't believe that the space is released after the rebuild. =Let's say you had a single-file filegroups with only one 100MB, =non-indexed table in it. If you created a clustered index on it, I'd =expect the file to be about 220MB when completed. This happens to me =when I rebuild large tables. I see it in my file growth and the free =space available in the file.
-- Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
.
"Tibor Karaszi" =<tibor.please_reply_to_public_forum.karaszi@.cornerstone.se> wrote in =message news:%23G$gqX4dDHA.2804@.TK2MSFTNGP11.phx.gbl...
... but that should be released after the rebuild is done. The =question is, I guess, how Jonathan checked the space used (file or table =level)? If at table level, how was that done (sysindexes was up-to-date =or not)? Also, assuming that able level and correct info, what did DBCC =SHOWCONTIG say (avg page density)?
-- Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=3Ddjq&as =ugroup=3Dmicrosoft.public.sqlserver
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:uw9AgZudDHA.3464@.TK2MSFTNGP11.phx.gbl...
When you create or rebuild a clustered index, SQL Server requires =1.2 X the size of the table in free space in order to do the sort.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Jonathan Lacefield" <Jonathan.lacefield@.solutionbuilders.com> wrote =in message news:002c01c376e5$98532500$a301280a@.phx.gbl...
I have been doing testing on tables sizes and I ran into a situation that I do not understand.
My default fill factor is set to 95%.
I used a SELECT INTO to copy a fact table for testing. The table was about 1.1 GB in size.
I then created a primary key /clustered index on an integer value on the new table. The table grew to about 1.9 GB in size.
I then truncated this table but left the index on it. I then ran an INSERT INTO statement to copy the origianl fact table.
The table was 1.1 GB in size and contained the clustered index.
Why would creating a clustered index increase a table's size when inserting into a table with an existing clustered index had no significant size difference? Doesn't the clustered index actually contain the data pages and therefore shouldn't affect the size of the table?
Thanks,
Jonathan Lacefield
MCDBA
--=_NextPart_000_0023_01C37776.32723E60
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

OK, perhaps he should run DBCC =UPDATEUSAGE (or sp_spaceused MyTable, true) and see if that gives him the right numbers.
-- Tom
---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql
"Tibor Karaszi" wrote in message news:O2YRAu4dDHA.568@.T=K2MSFTNGP11.phx.gbl...
Tom,
I was referring to the space *in* the =database file (the "table size"). Like a copy operation of a file. After you copied =the file, the sectors that the "old" file occupied are available for re-use. I =agree that the database file does not shrink in size after the =create/rebuild.
-- Tibor Karaszi, SQL Server MVPArchive at: http://groups.google.com/groups?oi=3Ddjq&as">http://groups.go=ogle.com/groups?oi=3Ddjq&as ugroup=3Dmicrosoft.public.sqlserver
"Tom Moreau" = wrote in message news:eiYE$r4dDHA.560@.t=k2msftngp13.phx.gbl...
Tibor, I don't believe that the =space is released after the rebuild. Let's say you had a single-file =filegroups with only one 100MB, non-indexed table in it. If you created a =clustered index on it, I'd expect the file to be about 220MB when =completed. This happens to me when I rebuild large tables. I see it in my file =growth and the free space available in the file.
-- Tom

----Thomas A. =Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql.
"Tibor Karaszi" wrote in message news:%23G$gqX4dDHA.=2804@.TK2MSFTNGP11.phx.gbl...
... but that should be released after =the rebuild is done. The question is, I guess, how Jonathan checked the space used =(file or table level)? If at table level, how was that done (sysindexes was up-to-date or not)? Also, assuming that able level and correct info, =what did DBCC SHOWCONTIG say (avg page density)?
-- Tibor Karaszi, SQL Server MVPArchive at: http://groups.google.com/groups?oi=3Ddjq&as">http://groups.go=ogle.com/groups?oi=3Ddjq&as ugroup=3Dmicrosoft.public.sqlserver


"Tom Moreau" = wrote in message news:uw9AgZudDHA.3464=@.TK2MSFTNGP11.phx.gbl...
When you create or rebuild a =clustered index, SQL Server requires 1.2 X the size of the table in free space in =order to do the sort.
-- Tom

=---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql


"Jonathan Lacefield" wrote in message news:002c01c376e5$98=532500$a301280a@.phx.gbl...I have been doing testing on tables sizes and I ran into a =situation that I do not understand.My default fill factor is set to =95%.I used a SELECT INTO to copy a fact table for testing. The =table was about 1.1 GB in size.I then created a primary key /clustered =index on an integer value on the new table. The table grew =to about 1.9 GB in size.I then truncated this table but left the =index on it. I then ran an INSERT INTO statement to copy the =origianl fact table.The table was 1.1 GB in size and contained the =clustered index.Why would creating a clustered index increase a =table's size when inserting into a table with an existing clustered =index had no significant size difference? Doesn't the clustered =index actually contain the data pages and therefore shouldn't affect =the size of the table?Thanks,Jonathan LacefieldMCDBA

--=_NextPart_000_0023_01C37776.32723E60--|||This is a multi-part message in MIME format.
--=_NextPart_000_0009_01C377AA.4FD990F0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Yep!
-- Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=3Ddjq&as =ugroup=3Dmicrosoft.public.sqlserver
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:OWw3te5dDHA.3680@.TK2MSFTNGP11.phx.gbl...
OK, perhaps he should run DBCC UPDATEUSAGE (or sp_spaceused MyTable, =true) and see if that gives him the right numbers.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Tibor Karaszi" =<tibor.please_reply_to_public_forum.karaszi@.cornerstone.se> wrote in =message news:O2YRAu4dDHA.568@.TK2MSFTNGP11.phx.gbl...
Tom,
I was referring to the space *in* the database file (the "table =size"). Like a copy operation of a file. After you copied the file, the =sectors that the "old" file occupied are available for re-use. I agree =that the database file does not shrink in size after the create/rebuild.
-- Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=3Ddjq&as =ugroup=3Dmicrosoft.public.sqlserver
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:eiYE$r4dDHA.560@.tk2msftngp13.phx.gbl...
Tibor, I don't believe that the space is released after the rebuild. = Let's say you had a single-file filegroups with only one 100MB, =non-indexed table in it. If you created a clustered index on it, I'd =expect the file to be about 220MB when completed. This happens to me =when I rebuild large tables. I see it in my file growth and the free =space available in the file.
-- Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
.
"Tibor Karaszi" =<tibor.please_reply_to_public_forum.karaszi@.cornerstone.se> wrote in =message news:%23G$gqX4dDHA.2804@.TK2MSFTNGP11.phx.gbl...
... but that should be released after the rebuild is done. The =question is, I guess, how Jonathan checked the space used (file or table =level)? If at table level, how was that done (sysindexes was up-to-date =or not)? Also, assuming that able level and correct info, what did DBCC =SHOWCONTIG say (avg page density)?
-- Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=3Ddjq&as =ugroup=3Dmicrosoft.public.sqlserver
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message =news:uw9AgZudDHA.3464@.TK2MSFTNGP11.phx.gbl...
When you create or rebuild a clustered index, SQL Server requires =1.2 X the size of the table in free space in order to do the sort.
-- Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Jonathan Lacefield" <Jonathan.lacefield@.solutionbuilders.com> =wrote in message news:002c01c376e5$98532500$a301280a@.phx.gbl...
I have been doing testing on tables sizes and I ran into a situation that I do not understand.
My default fill factor is set to 95%.
I used a SELECT INTO to copy a fact table for testing. The table was about 1.1 GB in size.
I then created a primary key /clustered index on an integer value on the new table. The table grew to about 1.9 GB in size.
I then truncated this table but left the index on it. I then ran an INSERT INTO statement to copy the origianl fact table.
The table was 1.1 GB in size and contained the clustered index.
Why would creating a clustered index increase a table's size when inserting into a table with an existing clustered index had no significant size difference? Doesn't the clustered index actually contain the data pages and therefore shouldn't affect the size of the table?
Thanks,
Jonathan Lacefield
MCDBA
--=_NextPart_000_0009_01C377AA.4FD990F0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Yep!
-- Tibor Karaszi, SQL Server MVPArchive at: http://groups.google.com/groups?oi=3Ddjq&as">http://groups.go=ogle.com/groups?oi=3Ddjq&as ugroup=3Dmicrosoft.public.sqlserver
"Tom Moreau" = wrote in message news:OWw3te5dDHA.3680=@.TK2MSFTNGP11.phx.gbl...
OK, perhaps he should run DBCC =UPDATEUSAGE (or sp_spaceused MyTable, true) and see if that gives him the right numbers.
-- Tom

=---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql


"Tibor Karaszi" wrote in message news:O2YRAu4dDHA.568@.T=K2MSFTNGP11.phx.gbl...
Tom,

I was referring to the space *in* the =database file (the "table size"). Like a copy operation of a file. After you =copied the file, the sectors that the "old" file occupied are available for =re-use. I agree that the database file does not shrink in size after the create/rebuild.
-- Tibor Karaszi, SQL Server MVPArchive at: http://groups.google.com/groups?oi=3Ddjq&as">http://groups.go=ogle.com/groups?oi=3Ddjq&as ugroup=3Dmicrosoft.public.sqlserver


"Tom Moreau" = wrote in message news:eiYE$r4dDHA.560@.t=k2msftngp13.phx.gbl...
Tibor, I don't believe that the =space is released after the rebuild. Let's say you had a single-file =filegroups with only one 100MB, non-indexed table in it. If you created a = clustered index on it, I'd expect the file to be about 220MB when completed. This happens to me when I rebuild large =tables. I see it in my file growth and the free space available in the =file.
-- Tom

----Thomas =A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, SQL =Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql.
"Tibor Karaszi" wrote in message news:%23G$gqX4dDHA.=2804@.TK2MSFTNGP11.phx.gbl...
... but that should be released =after the rebuild is done. The question is, I guess, how Jonathan checked the =space used (file or table level)? If at table level, how was that done =(sysindexes was up-to-date or not)? Also, assuming that able level and correct =info, what did DBCC SHOWCONTIG say (avg page density)?
-- Tibor Karaszi, SQL Server MVPArchive at: http://groups.google.com/groups?oi=3Ddjq&as">http://groups.go=ogle.com/groups?oi=3Ddjq&as ugroup=3Dmicrosoft.public.sqlserver


"Tom Moreau" = wrote in message news:uw9AgZudDHA.3464=@.TK2MSFTNGP11.phx.gbl...
When you create or rebuild a =clustered index, SQL Server requires 1.2 X the size of the table in free =space in order to do the sort.
-- Tom

=---T=homas A. Moreau, BSc, PhD, MCSE, MCDBASQL Server MVPColumnist, =SQL Server ProfessionalToronto, ON Canadahttp://www.pinnaclepublishing.com/sql">www.pinnaclepublishing.com=/sql


"Jonathan Lacefield" wrote in message news:002c01c376e5$98=532500$a301280a@.phx.gbl...I have been doing testing on tables sizes and I ran into a =situation that I do not understand.My default fill factor is set to 95%.I used a SELECT INTO to copy a fact table for =testing. The table was about 1.1 GB in size.I then created a =primary key /clustered index on an integer value on the new =table. The table grew to about 1.9 GB in size.I then =truncated this table but left the index on it. I then ran an INSERT =INTO statement to copy the origianl fact table.The table was =1.1 GB in size and contained the clustered index.Why would =creating a clustered index increase a table's size when inserting into a =table with an existing clustered index had no significant size difference? Doesn't the clustered index actually contain =the data pages and therefore shouldn't affect the size of the table?Thanks,Jonathan LacefieldMCDBA

--=_NextPart_000_0009_01C377AA.4FD990F0--|||It will take me a day or two to get the Stats on the
table. I used this table for testing and then dropped it
when I had completed the testing. I appreciate tour help
and info.
THanks
>--Original Message--
>Yep!
>--
>Tibor Karaszi, SQL Server MVP
>Archive at: http://groups.google.com/groups?oi=djq&as
ugroup=microsoft.public.sqlserver
>
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in
message news:OWw3te5dDHA.3680@.TK2MSFTNGP11.phx.gbl...
> OK, perhaps he should run DBCC UPDATEUSAGE (or
sp_spaceused MyTable, true) and see if that gives him the
right numbers.
> --
> Tom
> ---
--
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinnaclepublishing.com/sql
>
> "Tibor Karaszi"
<tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
wrote in message
news:O2YRAu4dDHA.568@.TK2MSFTNGP11.phx.gbl...
> Tom,
> I was referring to the space *in* the database file
(the "table size"). Like a copy operation of a file. After
you copied the file, the sectors that the "old" file
occupied are available for re-use. I agree that the
database file does not shrink in size after the
create/rebuild.
> --
> Tibor Karaszi, SQL Server MVP
> Archive at: http://groups.google.com/groups?oi=djq&as
ugroup=microsoft.public.sqlserver
>
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in
message news:eiYE$r4dDHA.560@.tk2msftngp13.phx.gbl...
> Tibor, I don't believe that the space is released
after the rebuild. Let's say you had a single-file
filegroups with only one 100MB, non-indexed table in it.
If you created a clustered index on it, I'd expect the
file to be about 220MB when completed. This happens to me
when I rebuild large tables. I see it in my file growth
and the free space available in the file.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinnaclepublishing.com/sql
> .
> "Tibor Karaszi"
<tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
wrote in message news:%
23G$gqX4dDHA.2804@.TK2MSFTNGP11.phx.gbl...
> ... but that should be released after the rebuild is
done. The question is, I guess, how Jonathan checked the
space used (file or table level)? If at table level, how
was that done (sysindexes was up-to-date or not)? Also,
assuming that able level and correct info, what did DBCC
SHOWCONTIG say (avg page density)?
> --
> Tibor Karaszi, SQL Server MVP
> Archive at: http://groups.google.com/groups?oi=djq&as
ugroup=microsoft.public.sqlserver
>
> "Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in
message news:uw9AgZudDHA.3464@.TK2MSFTNGP11.phx.gbl...
> When you create or rebuild a clustered index, SQL
Server requires 1.2 X the size of the table in free space
in order to do the sort.
> --
> Tom
> ----
--
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinnaclepublishing.com/sql
>
> "Jonathan Lacefield"
<Jonathan.lacefield@.solutionbuilders.com> wrote in message
news:002c01c376e5$98532500$a301280a@.phx.gbl...
> I have been doing testing on tables sizes and I ran
into a
> situation that I do not understand.
> My default fill factor is set to 95%.
> I used a SELECT INTO to copy a fact table for
testing.
> The table was about 1.1 GB in size.
> I then created a primary key /clustered index on an
> integer value on the new table.
> The table grew to about 1.9 GB in size.
> I then truncated this table but left the index on
it.
> I then ran an INSERT INTO statement to copy the
origianl
> fact table.
> The table was 1.1 GB in size and contained the
clustered
> index.
> Why would creating a clustered index increase a
table's
> size when inserting into a table with an existing
> clustered index had no significant size
difference?
> Doesn't the clustered index actually contain the
data
> pages and therefore shouldn't affect the size of
the table?
> Thanks,
> Jonathan Lacefield
> MCDBA

clustered index

Hi,
I have a table with 5 ints, 3 of them in an index.
I tested with a unclustered index and a clustered index.
The clustered one took more space!
? I expected the clustered one to take less space!
Can someone explain?
Thanx
Frank
The leaf level of clustered index contains data. In most situation, it
should occupy more space than non-clustered index.
Stephen Jiang
Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Frank" <frank@.frank.com> wrote in message
news:crhdfr$4g1$1@.news6.zwoll1.ov.home.nl...
> Hi,
> I have a table with 5 ints, 3 of them in an index.
> I tested with a unclustered index and a clustered index.
> The clustered one took more space!
> ? I expected the clustered one to take less space!
> Can someone explain?
> Thanx
> Frank
>
|||The leaf pages of the clustered index contain ALL the columns of the table
so a clustered index will usually be larger than a non-clustered one.
David Portas
SQL Server MVP
|||Clustered index is basically a table organized in b-tree structure so it is
basically size of table whereas non-clustered index only contians these 3
columns + rowid or clustered index so smaller than clustered index
"Frank" wrote:

> Hi,
> I have a table with 5 ints, 3 of them in an index.
> I tested with a unclustered index and a clustered index.
> The clustered one took more space!
> ? I expected the clustered one to take less space!
> Can someone explain?
> Thanx
> Frank
>
>
|||Thanks all,
but from the sqlbook I understand that the table IS the index. The book
says: the table is sorted on the the keyvalues or: the leaf (lowest) level
is actually the table. So no extra space is needed, only for the branches
leading to the leafs (dat).
Frank
"harvinder" <harvinder@.discussions.microsoft.com> schreef in bericht
news:F0F13A73-A7F7-4E9D-A381-79CD83301226@.microsoft.com...[vbcol=seagreen]
> Clustered index is basically a table organized in b-tree structure so it
> is
> basically size of table whereas non-clustered index only contians these 3
> columns + rowid or clustered index so smaller than clustered index
> "Frank" wrote:
|||I did some extra homework. My first test was creating a table and after
filling it I put an index on it. The clustered index turned out to be
bigger.
Second test I created the table with the clustered index and then filling
it. Now it was like I expected. The used dbspace is about equal to the data
alone. A test with a table with an unclustered index and then filling it
used up space to about twice the table data.
So my conclusion is: a clustered index is much smaller.
Frank
"Frank" <frank@.frank.com> schreef in bericht
news:crhdfr$4g1$1@.news6.zwoll1.ov.home.nl...
> Hi,
> I have a table with 5 ints, 3 of them in an index.
> I tested with a unclustered index and a clustered index. The clustered one
> took more space!
> ? I expected the clustered one to take less space!
> Can someone explain?
> Thanx
> Frank
>
|||> So my conclusion is: a clustered index is much smaller.
It depends on what you include in the index. A the leaf level of a clustered index is the data
pages. On top of that you have the non-leaf pages (which is rarely more than a few percent compared
to the data pages). So if you include the data pages, the index is table size plus non-leaf level.
Say you have a table of 100Mb and then create a clustered index, after that the table (with the
clustered index as the leaf level of the clustered index is the data pages) will occupy perhaps
103-107 Mb.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Frank" <frank@.frank.com> wrote in message news:crhgtj$jsi$1@.news2.zwoll1.ov.home.nl...
>I did some extra homework. My first test was creating a table and after filling it I put an index
>on it. The clustered index turned out to be bigger.
> Second test I created the table with the clustered index and then filling it. Now it was like I
> expected. The used dbspace is about equal to the data alone. A test with a table with an
> unclustered index and then filling it used up space to about twice the table data.
> So my conclusion is: a clustered index is much smaller.
> Frank
> "Frank" <frank@.frank.com> schreef in bericht news:crhdfr$4g1$1@.news6.zwoll1.ov.home.nl...
>
|||> So no extra space is needed, only for the branches leading to the leafs
> (dat).
You have answered your own question. Extra space IS needed. Both the data
and the B-tree are held within the clustered index.
David Portas
SQL Server MVP
|||On Wed, 5 Jan 2005 20:37:59 +0100, Frank wrote:

>Thanks all,
>but from the sqlbook I understand that the table IS the index.
Hi Frank,
Yes. Therefore, the size reported for the clustered index is the size of
all leaf pages (the table data) plus the size of the root and intermediate
levels of the B-tree.
A nonclustered index is smalle, since the leaf pages of this index store
only the indexed columns and a row locator (the columns of the clustered
index, if one is available, else a physical locator). Since the size of
indexed columns + columns in clustered index is typically less than the
size of the complete row, the nonclustered index itself (which is only the
index) takes less space than the clustered index (which is actually the
table plus the index).
Best, Hugo
(Remove _NO_ and _SPAM_ to get my e-mail address)

clustered index

Hi,
I have a table with 5 ints, 3 of them in an index.
I tested with a unclustered index and a clustered index.
The clustered one took more space!
? I expected the clustered one to take less space!
Can someone explain?
Thanx
FrankThe leaf level of clustered index contains data. In most situation, it
should occupy more space than non-clustered index.
Stephen Jiang
Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Frank" <frank@.frank.com> wrote in message
news:crhdfr$4g1$1@.news6.zwoll1.ov.home.nl...
> Hi,
> I have a table with 5 ints, 3 of them in an index.
> I tested with a unclustered index and a clustered index.
> The clustered one took more space!
> ? I expected the clustered one to take less space!
> Can someone explain?
> Thanx
> Frank
>|||The leaf pages of the clustered index contain ALL the columns of the table
so a clustered index will usually be larger than a non-clustered one.
David Portas
SQL Server MVP
--|||Clustered index is basically a table organized in b-tree structure so it is
basically size of table whereas non-clustered index only contians these 3
columns + rowid or clustered index so smaller than clustered index
"Frank" wrote:

> Hi,
> I have a table with 5 ints, 3 of them in an index.
> I tested with a unclustered index and a clustered index.
> The clustered one took more space!
> ? I expected the clustered one to take less space!
> Can someone explain?
> Thanx
> Frank
>
>|||Thanks all,
but from the sqlbook I understand that the table IS the index. The book
says: the table is sorted on the the keyvalues or: the leaf (lowest) level
is actually the table. So no extra space is needed, only for the branches
leading to the leafs (dat).
Frank
"harvinder" <harvinder@.discussions.microsoft.com> schreef in bericht
news:F0F13A73-A7F7-4E9D-A381-79CD83301226@.microsoft.com...[vbcol=seagreen]
> Clustered index is basically a table organized in b-tree structure so it
> is
> basically size of table whereas non-clustered index only contians these 3
> columns + rowid or clustered index so smaller than clustered index
> "Frank" wrote:
>|||I did some extra homework. My first test was creating a table and after
filling it I put an index on it. The clustered index turned out to be
bigger.
Second test I created the table with the clustered index and then filling
it. Now it was like I expected. The used dbspace is about equal to the data
alone. A test with a table with an unclustered index and then filling it
used up space to about twice the table data.
So my conclusion is: a clustered index is much smaller.
Frank
"Frank" <frank@.frank.com> schreef in bericht
news:crhdfr$4g1$1@.news6.zwoll1.ov.home.nl...
> Hi,
> I have a table with 5 ints, 3 of them in an index.
> I tested with a unclustered index and a clustered index. The clustered one
> took more space!
> ? I expected the clustered one to take less space!
> Can someone explain?
> Thanx
> Frank
>|||> So my conclusion is: a clustered index is much smaller.
It depends on what you include in the index. A the leaf level of a clustered
index is the data
pages. On top of that you have the non-leaf pages (which is rarely more than
a few percent compared
to the data pages). So if you include the data pages, the index is table siz
e plus non-leaf level.
Say you have a table of 100Mb and then create a clustered index, after that
the table (with the
clustered index as the leaf level of the clustered index is the data pages)
will occupy perhaps
103-107 Mb.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Frank" <frank@.frank.com> wrote in message news:crhgtj$jsi$1@.news2.zwoll1.ov.home.nl...[vbco
l=seagreen]
>I did some extra homework. My first test was creating a table and after fil
ling it I put an index
>on it. The clustered index turned out to be bigger.
> Second test I created the table with the clustered index and then filling
it. Now it was like I
> expected. The used dbspace is about equal to the data alone. A test with a
table with an
> unclustered index and then filling it used up space to about twice the tab
le data.
> So my conclusion is: a clustered index is much smaller.
> Frank
> "Frank" <frank@.frank.com> schreef in bericht news:crhdfr$4g1$1@.news6.zwoll
1.ov.home.nl...
>[/vbcol]|||> So no extra space is needed, only for the branches leading to the leafs
> (dat).
You have answered your own question. Extra space IS needed. Both the data
and the B-tree are held within the clustered index.
David Portas
SQL Server MVP
--|||On Wed, 5 Jan 2005 20:37:59 +0100, Frank wrote:

>Thanks all,
>but from the sqlbook I understand that the table IS the index.
Hi Frank,
Yes. Therefore, the size reported for the clustered index is the size of
all leaf pages (the table data) plus the size of the root and intermediate
levels of the B-tree.
A nonclustered index is smalle, since the leaf pages of this index store
only the indexed columns and a row locator (the columns of the clustered
index, if one is available, else a physical locator). Since the size of
indexed columns + columns in clustered index is typically less than the
size of the complete row, the nonclustered index itself (which is only the
index) takes less space than the clustered index (which is actually the
table plus the index).
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

clustered index

Hi,
I have a table with 5 ints, 3 of them in an index.
I tested with a unclustered index and a clustered index.
The clustered one took more space!
? I expected the clustered one to take less space!
Can someone explain?
Thanx
FrankThe leaf pages of the clustered index contain ALL the columns of the table
so a clustered index will usually be larger than a non-clustered one.
--
David Portas
SQL Server MVP
--|||The leaf level of clustered index contains data. In most situation, it
should occupy more space than non-clustered index.
Stephen Jiang
Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Frank" <frank@.frank.com> wrote in message
news:crhdfr$4g1$1@.news6.zwoll1.ov.home.nl...
> Hi,
> I have a table with 5 ints, 3 of them in an index.
> I tested with a unclustered index and a clustered index.
> The clustered one took more space!
> ? I expected the clustered one to take less space!
> Can someone explain?
> Thanx
> Frank
>|||Clustered index is basically a table organized in b-tree structure so it is
basically size of table whereas non-clustered index only contians these 3
columns + rowid or clustered index so smaller than clustered index
"Frank" wrote:
> Hi,
> I have a table with 5 ints, 3 of them in an index.
> I tested with a unclustered index and a clustered index.
> The clustered one took more space!
> ? I expected the clustered one to take less space!
> Can someone explain?
> Thanx
> Frank
>
>|||Thanks all,
but from the sqlbook I understand that the table IS the index. The book
says: the table is sorted on the the keyvalues or: the leaf (lowest) level
is actually the table. So no extra space is needed, only for the branches
leading to the leafs (dat).
Frank
"harvinder" <harvinder@.discussions.microsoft.com> schreef in bericht
news:F0F13A73-A7F7-4E9D-A381-79CD83301226@.microsoft.com...
> Clustered index is basically a table organized in b-tree structure so it
> is
> basically size of table whereas non-clustered index only contians these 3
> columns + rowid or clustered index so smaller than clustered index
> "Frank" wrote:
>> Hi,
>> I have a table with 5 ints, 3 of them in an index.
>> I tested with a unclustered index and a clustered index.
>> The clustered one took more space!
>> ? I expected the clustered one to take less space!
>> Can someone explain?
>> Thanx
>> Frank
>>|||I did some extra homework. My first test was creating a table and after
filling it I put an index on it. The clustered index turned out to be
bigger.
Second test I created the table with the clustered index and then filling
it. Now it was like I expected. The used dbspace is about equal to the data
alone. A test with a table with an unclustered index and then filling it
used up space to about twice the table data.
So my conclusion is: a clustered index is much smaller.
Frank
"Frank" <frank@.frank.com> schreef in bericht
news:crhdfr$4g1$1@.news6.zwoll1.ov.home.nl...
> Hi,
> I have a table with 5 ints, 3 of them in an index.
> I tested with a unclustered index and a clustered index. The clustered one
> took more space!
> ? I expected the clustered one to take less space!
> Can someone explain?
> Thanx
> Frank
>|||> So my conclusion is: a clustered index is much smaller.
It depends on what you include in the index. A the leaf level of a clustered index is the data
pages. On top of that you have the non-leaf pages (which is rarely more than a few percent compared
to the data pages). So if you include the data pages, the index is table size plus non-leaf level.
Say you have a table of 100Mb and then create a clustered index, after that the table (with the
clustered index as the leaf level of the clustered index is the data pages) will occupy perhaps
103-107 Mb.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Frank" <frank@.frank.com> wrote in message news:crhgtj$jsi$1@.news2.zwoll1.ov.home.nl...
>I did some extra homework. My first test was creating a table and after filling it I put an index
>on it. The clustered index turned out to be bigger.
> Second test I created the table with the clustered index and then filling it. Now it was like I
> expected. The used dbspace is about equal to the data alone. A test with a table with an
> unclustered index and then filling it used up space to about twice the table data.
> So my conclusion is: a clustered index is much smaller.
> Frank
> "Frank" <frank@.frank.com> schreef in bericht news:crhdfr$4g1$1@.news6.zwoll1.ov.home.nl...
>> Hi,
>> I have a table with 5 ints, 3 of them in an index.
>> I tested with a unclustered index and a clustered index. The clustered one took more space!
>> ? I expected the clustered one to take less space!
>> Can someone explain?
>> Thanx
>> Frank
>|||> So no extra space is needed, only for the branches leading to the leafs
> (dat).
You have answered your own question. Extra space IS needed. Both the data
and the B-tree are held within the clustered index.
--
David Portas
SQL Server MVP
--|||On Wed, 5 Jan 2005 20:37:59 +0100, Frank wrote:
>Thanks all,
>but from the sqlbook I understand that the table IS the index.
Hi Frank,
Yes. Therefore, the size reported for the clustered index is the size of
all leaf pages (the table data) plus the size of the root and intermediate
levels of the B-tree.
A nonclustered index is smalle, since the leaf pages of this index store
only the indexed columns and a row locator (the columns of the clustered
index, if one is available, else a physical locator). Since the size of
indexed columns + columns in clustered index is typically less than the
size of the complete row, the nonclustered index itself (which is only the
index) takes less space than the clustered index (which is actually the
table plus the index).
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)