我有一个表,其中包含表中的 2 个 cr 记录。我正在尝试根据月份和年份进行分区。
我尝试创建此表的文件组,但在我的场景中,该表在预编码部分的许多地方都使用。有什么办法可以让我对这个表进行分区并在 BI 报告中使用它,这样预编程就不会产生影响。
对于版本: - 我有以下非常基本的查询,但需要 10 分钟才能运行。
这是执行计划 - https://www.brentozar.com/pastetheplan/?id=B1dy0ZQ6d
任何人都可以看到改进它的方法吗?让我知道一些示例数据/表结构是否有用。
E2E_TBL_LIQUIDITY_TRACKING_CFY_JUNE 有 899556 条记录 LQTFYOpeningStock 有 934878 条记录 E2E_TBL_CPL_SALES_MR_008 有 131491 条记录 E2E_TBL_MATERIAL_MASTER 有 4695 条记录 LocationNameView 有 477 条记录 E2e_Tbl_Customer_Master 有 20390 条记录 E2_Master 有 20390 条记录
以下是索引: -
CREATE NONCLUSTERED INDEX [Index1LQt] ON [dbo].[E2E_TBL_LIQUIDITY_TRACKING_CFY_JUNE]
(
[Territory_Code] ASC
)
INCLUDE ( [Customer_Code],
[Product_Code],[LOB_Code],[Distributor_Stock],[Dealers_Stock],[L3_Price],[L1_Price],[L2_Price])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [Index2LQt] ON [dbo].[LQTFYOpeningStock]
(
[Customer_Code] ASC,
[Product_Code] ASC,
[Territory_Code] ASC,
[LOB_Code] ASC
)
INCLUDE ( [StockValueL1],
[StockValueL2],
[StockValueL3]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [Index3LQt] ON [dbo].[LQTFYOpeningStock]
(
[Territory_Code] ASC
)
INCLUDE ( [Customer_Code],
[Product_Code],
[LOB_Code],
[StockValueL1],
[StockValueL2],
[StockValueL3]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
ALTER TABLE [dbo].[E2E_TBL_CPL_SALES_MR_008] ADD CONSTRAINT [PK_MR008] PRIMARY KEY CLUSTERED
(
[Territory_Code] ASC,
[Customer_Code] ASC,
[Product] ASC,
[SKU] ASC,
[LOB] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO