我有3个系统:
Billing System
Tax System
AmericaGreatAgain System
...直接与我的数据库对话。
Employee table
columns: pk, ssn, last, first, dob
为了适应所有三个系统,它是否是在同一个Employee表上创建视图的标准解决方案,以满足其消费者的索引需求?
在以下示例中,我们将创建一个视图并为该视图编制索引:
CREATE VIEW Sales.vSalesSummaryCustomerProduct
WITH SCHEMABINDING
AS
SELECT CUST.CustomerID ,
SOH.SalesOrderID ,
SOD.ProductID ,
SUM(SOD.OrderQty) AS TotalOrderQty ,
SUM(LineTotal) AS TotalValue ,
COUNT_BIG(*) AS CountLines
FROM Sales.SalesOrderHeader SOH
INNER JOIN Sales.SalesOrderDetail SOD
ON SOH.SalesOrderID = SOD.SalesOrderID
INNER JOIN Production.Product PROD
ON PROD.ProductID = SOD.ProductID
INNER JOIN Sales.Customer CUST
ON SOH.CustomerID = CUST.CustomerID
INNER JOIN Person.Person PER
ON PER.BusinessEntityID = CUST.PersonID
GROUP BY CUST.CustomerID ,
SOH.SalesOrderID ,
SOD.ProductID;
GO
CREATE UNIQUE CLUSTERED INDEX CX_vSalesSummaryCustomerProduct
ON Sales.vSalesSummaryCustomerProduct(CustomerID, SalesOrderID, ProductID);
GO
问题是,同一结果集需要一个单独的索引:
CREATE VIEW Sales.vSalesSummaryCustomerProduct1 ---- new one
WITH SCHEMABINDING
AS
SELECT CUST.CustomerID ,
SOH.SalesOrderID ,
--etc
index on another column
CREATE VIEW Sales.vSalesSummaryCustomerProduct2 ---- new one
WITH SCHEMABINDING
AS
SELECT CUST.CustomerID ,
SOH.SalesOrderID ,
--etc
index on another column
通过简单地创建相同BASE数据的许多视图来创建这种类型的速度优化策略是什么标准做法,创建所需的索引?