Amm*_*arR 2 performance index sql-server-2008 facttable query-performance
我有一个事实表 CardTransactionFact
表结构
TABLE [dbo].[CardTransactionFact]
[CardTransactionID] [int] IDENTITY(1,1) NOT NULL,
[TransactionTerminalID] [int] NOT NULL,
[SourceAccountTypeID] [int] NULL,
[DestinationAccountTypeID] [int] NULL,
[RimNo] [varchar](15) NULL,
[CaptureCodeID] [int] NOT NULL,
[RoutingCodeID] [int] NOT NULL,
[ProcessingCodeID] [int] NOT NULL,
[ActionCodeID] [int] NOT NULL,
[NetworkCodeID] [int] NOT NULL,
[ProductCodeID] [int] NOT NULL,
[AcquiringCountryCodeID] [int] NOT NULL,
[IssuingCountryCodeID] [int] NOT NULL,
[TransactionCurrencyCodeID] [int] NOT NULL,
[AmountBD] [decimal](18, 3) NOT NULL,
[LocalCurrencyCodeID] [int] NOT NULL,
[CardIssuerBank] [int] NOT NULL,
[CardTypeID] [int] NOT NULL,
[SuspectTransactionFlag] [char](1) NOT NULL,
[ReversalTransactionFlag] [char](1) NOT NULL,
[LocalTransactionDateKey] [int] NOT NULL,
[LocalTransactionHourKey] [int] NOT NULL,
[BBKRole] [char](1) NOT NULL,
[AmountRangeKey] [int] NULL,
[CustomerKey] [int] NULL
Run Code Online (Sandbox Code Playgroud)
大小:11GB 行数:56,959,828
现在访问这个表变得非常困难,一个简单的Select count(*) from CardTransactionFact
需要几个小时才能执行。
表中的大多数列只是整数,这就是我没有做任何索引的原因。
你认为我应该怎么做来改进这张表,并提高对这张表的查询速度
这里有很多错误,值得庆幸的是很多可以修复。
问题:
修复:
11GB 装不下 6GB,真的就是这么简单。一个非常粗略的估计表明该表将占用约 150 万个 8KB 页面,在 100 IOPS 的情况下,从磁盘读取大约需要 4 小时(假设最坏的情况,100% 随机读取,没有预读等)。
归档时间: |
|
查看次数: |
2261 次 |
最近记录: |