Merge remote-tracking branch 'origin/master'
This commit is contained in:
87
scripts/sql/product_filter_tr_cache_refresh.sql
Normal file
87
scripts/sql/product_filter_tr_cache_refresh.sql
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Product filter cache refresh for Product Stock By Attributes endpoints.
|
||||
This cache is used by backend queries when dbo.ProductFilterTRCache exists.
|
||||
*/
|
||||
|
||||
USE BAGGI_V3;
|
||||
GO
|
||||
|
||||
IF OBJECT_ID('dbo.ProductFilterTRCache','U') IS NULL
|
||||
BEGIN
|
||||
CREATE TABLE dbo.ProductFilterTRCache
|
||||
(
|
||||
ProductCode NVARCHAR(50) NOT NULL PRIMARY KEY,
|
||||
ProductDescription NVARCHAR(255) NULL,
|
||||
ProductAtt01Desc NVARCHAR(255) NULL,
|
||||
ProductAtt02Desc NVARCHAR(255) NULL,
|
||||
ProductAtt11Desc NVARCHAR(255) NULL,
|
||||
ProductAtt38Desc NVARCHAR(255) NULL,
|
||||
ProductAtt41Desc NVARCHAR(255) NULL,
|
||||
ProductAtt44Desc NVARCHAR(255) NULL
|
||||
);
|
||||
END
|
||||
GO
|
||||
|
||||
TRUNCATE TABLE dbo.ProductFilterTRCache;
|
||||
GO
|
||||
|
||||
INSERT INTO dbo.ProductFilterTRCache
|
||||
(
|
||||
ProductCode,
|
||||
ProductDescription,
|
||||
ProductAtt01Desc,
|
||||
ProductAtt02Desc,
|
||||
ProductAtt11Desc,
|
||||
ProductAtt38Desc,
|
||||
ProductAtt41Desc,
|
||||
ProductAtt44Desc
|
||||
)
|
||||
SELECT
|
||||
ProductCode,
|
||||
ProductDescription,
|
||||
ProductAtt01Desc,
|
||||
ProductAtt02Desc,
|
||||
ProductAtt11Desc,
|
||||
ProductAtt38Desc,
|
||||
ProductAtt41Desc,
|
||||
ProductAtt44Desc
|
||||
FROM ProductFilterWithDescription('TR')
|
||||
WHERE LEN(ProductCode) = 13;
|
||||
GO
|
||||
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM sys.indexes
|
||||
WHERE name = 'IX_ProductFilterTRCache_Filter'
|
||||
AND object_id = OBJECT_ID('dbo.ProductFilterTRCache')
|
||||
)
|
||||
BEGIN
|
||||
DROP INDEX IX_ProductFilterTRCache_Filter ON dbo.ProductFilterTRCache;
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM sys.indexes
|
||||
WHERE name = 'IX_ProductFilterTRCache_KatAna'
|
||||
AND object_id = OBJECT_ID('dbo.ProductFilterTRCache')
|
||||
)
|
||||
BEGIN
|
||||
CREATE NONCLUSTERED INDEX IX_ProductFilterTRCache_KatAna
|
||||
ON dbo.ProductFilterTRCache (ProductAtt44Desc, ProductAtt01Desc, ProductCode)
|
||||
INCLUDE (ProductDescription, ProductAtt02Desc, ProductAtt41Desc, ProductAtt38Desc, ProductAtt11Desc);
|
||||
END
|
||||
GO
|
||||
|
||||
IF NOT EXISTS (
|
||||
SELECT 1 FROM sys.indexes
|
||||
WHERE name = 'IX_ProductFilterTRCache_KatAnaAlt'
|
||||
AND object_id = OBJECT_ID('dbo.ProductFilterTRCache')
|
||||
)
|
||||
BEGIN
|
||||
CREATE NONCLUSTERED INDEX IX_ProductFilterTRCache_KatAnaAlt
|
||||
ON dbo.ProductFilterTRCache (ProductAtt44Desc, ProductAtt01Desc, ProductAtt02Desc, ProductCode)
|
||||
INCLUDE (ProductDescription, ProductAtt41Desc, ProductAtt38Desc, ProductAtt11Desc);
|
||||
END
|
||||
GO
|
||||
|
||||
UPDATE STATISTICS dbo.ProductFilterTRCache WITH FULLSCAN;
|
||||
GO
|
||||
74
scripts/sql/product_stock_by_attributes_indexes.sql
Normal file
74
scripts/sql/product_stock_by_attributes_indexes.sql
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
Performance indexes for Product Stock By Attributes queries.
|
||||
Target: SQL Server
|
||||
*/
|
||||
|
||||
/* trStock (inventory aggregation) */
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.indexes
|
||||
WHERE name = 'IX_trStock_Item_Warehouse_Dims'
|
||||
AND object_id = OBJECT_ID('dbo.trStock')
|
||||
)
|
||||
BEGIN
|
||||
CREATE NONCLUSTERED INDEX IX_trStock_Item_Warehouse_Dims
|
||||
ON dbo.trStock (ItemTypeCode, ItemCode, WarehouseCode, ColorCode, ItemDim1Code, ItemDim2Code, ItemDim3Code)
|
||||
INCLUDE (In_Qty1, Out_Qty1, CompanyCode, OfficeCode, StoreTypeCode, StoreCode);
|
||||
END;
|
||||
GO
|
||||
|
||||
/* PickingStates */
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.indexes
|
||||
WHERE name = 'IX_PickingStates_Item_Warehouse_Dims'
|
||||
AND object_id = OBJECT_ID('dbo.PickingStates')
|
||||
)
|
||||
BEGIN
|
||||
CREATE NONCLUSTERED INDEX IX_PickingStates_Item_Warehouse_Dims
|
||||
ON dbo.PickingStates (ItemTypeCode, ItemCode, WarehouseCode, ColorCode, ItemDim1Code, ItemDim2Code, ItemDim3Code)
|
||||
INCLUDE (Qty1, CompanyCode, OfficeCode, StoreTypeCode, StoreCode);
|
||||
END;
|
||||
GO
|
||||
|
||||
/* ReserveStates */
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.indexes
|
||||
WHERE name = 'IX_ReserveStates_Item_Warehouse_Dims'
|
||||
AND object_id = OBJECT_ID('dbo.ReserveStates')
|
||||
)
|
||||
BEGIN
|
||||
CREATE NONCLUSTERED INDEX IX_ReserveStates_Item_Warehouse_Dims
|
||||
ON dbo.ReserveStates (ItemTypeCode, ItemCode, WarehouseCode, ColorCode, ItemDim1Code, ItemDim2Code, ItemDim3Code)
|
||||
INCLUDE (Qty1, CompanyCode, OfficeCode, StoreTypeCode, StoreCode);
|
||||
END;
|
||||
GO
|
||||
|
||||
/* DispOrderStates */
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.indexes
|
||||
WHERE name = 'IX_DispOrderStates_Item_Warehouse_Dims'
|
||||
AND object_id = OBJECT_ID('dbo.DispOrderStates')
|
||||
)
|
||||
BEGIN
|
||||
CREATE NONCLUSTERED INDEX IX_DispOrderStates_Item_Warehouse_Dims
|
||||
ON dbo.DispOrderStates (ItemTypeCode, ItemCode, WarehouseCode, ColorCode, ItemDim1Code, ItemDim2Code, ItemDim3Code)
|
||||
INCLUDE (Qty1, CompanyCode, OfficeCode, StoreTypeCode, StoreCode);
|
||||
END;
|
||||
GO
|
||||
|
||||
/* Latest price lookup */
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM sys.indexes
|
||||
WHERE name = 'IX_prItemBasePrice_ItemType_ItemCode_PriceDate'
|
||||
AND object_id = OBJECT_ID('dbo.prItemBasePrice')
|
||||
)
|
||||
BEGIN
|
||||
CREATE NONCLUSTERED INDEX IX_prItemBasePrice_ItemType_ItemCode_PriceDate
|
||||
ON dbo.prItemBasePrice (ItemTypeCode, ItemCode, PriceDate DESC)
|
||||
INCLUDE (Price);
|
||||
END;
|
||||
GO
|
||||
Reference in New Issue
Block a user