Ich habe eine partitionierte Ansicht, die den folgenden Einfügetrigger hat (Partition des schlechten Mannes). Wenn ich ein LÖSCHEN durchführe, erhalte ich den folgenden Abfrageplan:
delete from factproductprice where pricedate = '20170725'
Auslöser für die Ansicht:
ALTER TRIGGER [dbo].[factProductPriceDelete] ON [dbo].[FactProductPrice]
INSTEAD OF DELETE AS
BEGIN
IF @@ROWCOUNT = 0 RETURN;
DECLARE @PriceDate DATE
SELECT @PriceDate = CAST(PriceDate AS DATE) FROM DELETED
IF @PriceDate BETWEEN '20140101' AND '20141231'
BEGIN
DELETE FROM dbo.FactProductPrice2014
WHERE ProductId IN (SELECT ProductId FROM DELETED) AND SalesPriceSchemeId IN (SELECT SalesPriceSchemeId FROM DELETED) AND PriceDate IN (SELECT PriceDate FROM DELETED)
END
IF @PriceDate BETWEEN '20150101' AND '20151231'
BEGIN
DELETE FROM dbo.FactProductPrice2015
WHERE ProductId IN (SELECT ProductId FROM DELETED) AND SalesPriceSchemeId IN (SELECT SalesPriceSchemeId FROM DELETED) AND PriceDate IN (SELECT PriceDate FROM DELETED)
END
IF @PriceDate BETWEEN '20160101' AND '20161231'
.... usw