Re: Size of SQLServer databases with indices
From: Erland Sommarskog (esquel_at_sommarskog.se)
Date: 07/23/04
- Next message: Bart Torbert: "Re: Size of SQLServer databases with indices"
- Previous message: Bart Torbert: "Size of SQLServer databases with indices"
- In reply to: Bart Torbert: "Size of SQLServer databases with indices"
- Next in thread: Bart Torbert: "Re: Size of SQLServer databases with indices"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 23 Jul 2004 22:13:07 +0000 (UTC)
Bart Torbert (barthome1@comcast.net) writes:
> I am starting to examine using SQLServer instead of Oracle. I went
> through the SQLServer import utility to copy tables from Oracle into
> SQLServer. I then checked the size of the database.
>
> I then started to specify indices for the tables. I did not see the
> database file size grow all that much. I kept on using the shrink
> command to make sure that wasted space was removed. I even made sure
> that minimal free space was allowed.
>
> I was rather expecting (from experience with Oracle) that there would
> be a large growth in the database when addind indices. So what did I
> miss? Are the indices stored elsewhere and I missed them? Does
> SQLServer handle indices differently so they dont' bloat the database
> size?
I cannot compare with Oracle, since I don't have any experience of
Oracle.
In SQL Server, yes, indexes take up space. But it depends a little on
what sort of index you add. A clustered index, has the data as its
leaf pages, which means that only the index tree itself takes up space.
To find out how much space you use on indexes for a certain table, you
can do:
sp_spaceused tbl, TRUE
(The second parameter forces an update of usage data.)
To see the overall database size, it's better to use sp_spaceused with
NULL as the first parameter. The second result set, gives you four
numbers:
reserved: this how much space that has been reserved for the table.
data: data + clustered index if there is one.
index: non-clustered indexes.
unused: reserved space, which is not occupied by data or indexes yet.
Since SQL Server allocates space in extents of eight pages at a time,
there is always some unused space. But with heavy fragmentation, this
value can grow.
reserved = data + indexes + unused.
-- Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
- Next message: Bart Torbert: "Re: Size of SQLServer databases with indices"
- Previous message: Bart Torbert: "Size of SQLServer databases with indices"
- In reply to: Bart Torbert: "Size of SQLServer databases with indices"
- Next in thread: Bart Torbert: "Re: Size of SQLServer databases with indices"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|