开发者

Does Sql Server Compress Database size on similar data

开发者 https://www.devze.com 2022-12-21 04:05 出处:网络
Just to find out my would be DB size on production environment, I just populated my tables with 1.5 million rows of nearly same data (Except Primary key).It currently shows 261 MB...

Just to find out my would be DB size on production environment, I just populated my tables with 1.5 million rows of nearly same data (Except Primary key). It currently shows 261 MB...

Now, Whether I can rely on this, or since the Data is almost similar on all other columns the SQL server has compressed the size. ie. Will the size be different if the values in each 开发者_StackOverflow社区rows are different...

Further.. Does even columns will null values contribute to the size of the DB ?

Thanks for your time...

Edit : Here is my schema... And I have made some indexes too...

    CREATE TABLE [dbo].[Trn_Tickets](
        [ObjectID] [bigint] IDENTITY(1,1) NOT NULL,
        [TicketSeqNo] [bigint] NULL,
        [BookSeqNo] [bigint] NULL,
        [MatchID] [int] NULL,
        [TicketNumber] [varchar](20) NULL,
        [BarCodeNumber] [varchar](20) NULL,
        [GateNo] [varchar](5) NULL,
        [EntryFrom] [varchar](10) NULL,
        [MRP] [decimal](9, 2) NULL,
        [Commission] [decimal](9, 2) NULL,
        [Discount] [decimal](9, 2) NULL,
        [CashPrice] [decimal](9, 2) NULL,
        [CashReceived] [decimal](9, 2) NULL,
        [BalanceDue] [decimal](9, 2) NULL,
        [CollectibleFrom] [char](1) NULL,
        [PlaceOfIssue] [varchar](20) NULL,
        [DateOfIssue] [datetime] NULL,
        [PlaceOfSale] [varchar](20) NULL,
        [AgentID] [int] NULL,
        [BuyerID] [int] NULL,
        [SaleTypeID] [tinyint] NULL,
        [SaleDate] [smalldatetime] NULL,
        [ApprovedBy] [varchar](15) NULL,
        [ApprovedDate] [smalldatetime] NULL,
        [InvoiceStatus] [char](1) NULL,
        [InvoiceRefNo] [varchar](15) NULL,
        [InvoiceDate] [smalldatetime] NULL,
        [BookPosition] [char](2) NULL,
        [TicketStatus] [char](2) NULL,
        [RecordStatus] [char](1) NULL,
        [ClosingStatus] [char](2) NULL,
        [ClosingDate] [datetime] NULL,
        [UpdatedDate] [datetime] NULL,
        [UpdatedUser] [varchar](10) NULL,
     CONSTRAINT [PK_Trn_Tickets] PRIMARY KEY CLUSTERED 
    (
        [ObjectID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]

Hope this helps


SQL Server 2005 and 2008 Express will not compress your data. SQL Server 2008 can use page compression, but only on Enterprise Edition. NULL columns occupy one bit in the row.

From the description of your data, sounds more like a problem of ordinary normalization. Separate the repeat values into a lookup table, store only distinct combinations, join agaisnt the lookup table. This will save data by schema design and will work on all DB platforms, all versions, all SKUs.


Replace ApprovedBy etc (varchar) with lookups to other tables

Do you need datetime?

Do you expect more then 4 billion rows? Why are the 1st 3 cols bigint?

Save a few bytes here and there = a big difference. Higher page density (eg more rows per 8k page) = less space + smaller indexes.

Compress when you have 1.5 billion rows.

0

精彩评论

暂无评论...
验证码 换一张
取 消