Wir haben dieses wirklich seltsame Verhalten, das wir gerade mit unseren Update-Intersect-Anweisungen erlebt haben. Diese haben gut funktioniert, aber jetzt nehmen wir eine ziemlich breite Datenquelle in Bezug auf Spalten auf und verlangsamen sich allmählich, bis sie auf unbestimmte Zeit hängen bleiben.
Die folgende Abfrage wird immer länger, wenn wir Daten in Gruppen von etwa 20.000 Zeilen (was sehr klein ist) hinzufügen und ungefähr 70.000 Zeilen hängen. Es werden keine Indizes verwendet. Wir löschen sie, bevor wir die Daten aufnehmen.
Hier ist die Aussage:
UPDATE Staging.[TdDailyPerformance]
SET [SYS_OPERATION] = 'U'
FROM (
SELECT [HashCode]
FROM Staging.[TdDailyPerformance]
INTERSECT
SELECT [HashCode]
FROM [IdMatch].[TdDailyPerformance]
) AS A
Ausführungsplan:
Jetzt funktioniert diese Abfrage an vielen anderen Stellen auf unserem Server, aber nicht hier. Das Interessante ist, dass unabhängig davon, ob die INTERSECT
Zeilen zurückgegeben werden, die Abfrage für immer hängt (ich teste dies, indem ich den Schnittpunkt unabhängig ausführe - es dauert weniger als 2 ms).
Laut SQL sollte es nicht funktionieren, aber es funktioniert. Wenn das HasCode
in der Staging
Tabelle bereits in der IdMatch
Tabelle vorhanden ist, wird das [SYS_OPERATION]
der Staging
Tabelle auf "U" aktualisiert . Wir verwenden dies an mehreren Stellen und es ist erst kürzlich bei diesem einen Datensatz fehlgeschlagen.
Irgendwelche Ideen, was dies verursachen könnte?
Keine Blockierung, soweit wir sehen können. Die einzigen Wartezeiten bei der Transaktion sind die, CXPACKET
die ich vom QP erwarten würde. Ich habe abgefragt sp_who2
, alle Transaktionen und den Aktivitätsmonitor überprüft, um Blöcke zu identifizieren, und nichts gefunden. Ich habe nicht verfolgt.
Meistens funktionieren unsere Tests jetzt so, dass es 0 Zeilen hat, wenn es hängt. Aber wir haben überprüft, dass es auch mit 1-100 Zeilen hängt, dass INTERSECT
.
IdMatch
hat keine HashCodes
, die in existieren Staging
, aber beide Tabellen haben zum Zeitpunkt des Hängens ungefähr 70K Zeilen. Um klar zu sein, haben beide Tabellen ungefähr 70 KB, aber der Schnittpunkt in HashCode
beträgt 0 Zeilen.
Wir haben mit Indizes getestet. Wir erhalten insgesamt eine schlechte Leistung, bevor wir die betreffende Abfrage treffen. Der Index fragmentiert einfach zu schnell, um hilfreich zu sein.
Tabellendefinitionen
Staging.TdDailyPerformance
CREATE TABLE [Staging].[TdDailyPerformance]
(
[ID] INT NOT NULL,
[SYS_OPERATION] CHAR(8) NULL,
[HashCode] BINARY(65) NULL,
[Ad Environment] NVARCHAR(1024) NULL,
[Ad Format] NVARCHAR(10) NULL,
[Ad Group] NVARCHAR(1024) NULL,
[Ad Group ID] NVARCHAR(32) NULL,
[Ad Server Creative Placement ID] NVARCHAR(1024) NULL,
[Ad Server Name] NVARCHAR(1024) NULL,
[Advertiser] NVARCHAR(1024) NULL,
[Advertiser Currency Code] NVARCHAR(32) NULL,
[Advertiser ID] NVARCHAR(32) NULL,
[App] NVARCHAR(1024) NULL,
[Audience] NVARCHAR(1024) NULL,
[Audience ID] NVARCHAR(32) NULL,
[Browser] NVARCHAR(30) NULL,
[Campaign] NVARCHAR(1024) NULL,
[Campaign ID] NVARCHAR(32) NULL,
[Carrier ID] INT NULL,
[Carrier Name] NVARCHAR(1024) NULL,
[Category ID] NVARCHAR(1024) NULL,
[Category Name] NVARCHAR(1024) NULL,
[City] NVARCHAR(50) NULL,
[Country] NVARCHAR(50) NULL,
[Creative] NVARCHAR(1024) NULL,
[Creative Duration In Seconds] INT NULL,
[Creative ID] NVARCHAR(32) NULL,
[Date] NVARCHAR(1024) NULL,
[Deal ID] NVARCHAR(128) NULL,
[Device Make] NVARCHAR(32) NULL,
[Device Type] NVARCHAR(15) NULL,
[Fold] NVARCHAR(128) NULL,
[Language] NVARCHAR(1024) NULL,
[Market Type] NVARCHAR(32) NULL,
[Media Type] NVARCHAR(32) NULL,
[Metro] NVARCHAR(128) NULL,
[Metro Code] INT NULL,
[Operating System] NVARCHAR(32) NULL,
[Operating System Family] NVARCHAR(1024) NULL,
[Partner ID] NVARCHAR(32) NULL,
[Partner Name] NVARCHAR(32) NULL,
[Recency Group] NVARCHAR(32) NULL,
[Recency Group End In Minutes] INT NULL,
[Recency Group Start In Minutes] INT NULL,
[Region] NVARCHAR(128) NULL,
[Site] NVARCHAR(128) NULL,
[Site List Name] NVARCHAR(1024) NULL,
[Site/Category Bid Factor] NVARCHAR(1024) NULL,
[Supply Vendor] NVARCHAR(25) NULL,
[Supply Vendor Publisher Id] NVARCHAR(64) NULL,
[Timezone] NVARCHAR(1024) NULL,
[Video Playback Type] NVARCHAR(32) NULL,
[Whitelist Site] NVARCHAR(32) NULL,
[Partner Currency Code] NVARCHAR(1024) NULL,
[Additional Fee Cost (Adv Currency)] DECIMAL(37,15) NULL,
[Additional Fee Cost (Partner Currency)] DECIMAL(37,15) NULL,
[Additional Fee Cost (USD)] DECIMAL(37,15) NULL,
[Advertiser Cost (Adv Currency)] DECIMAL(37,15) NULL,
[Advertiser Cost (Partner Currency)] DECIMAL(37,15) NULL,
[Advertiser Cost (USD)] DECIMAL(37,15) NULL,
[All Last Click + View Conversions] INT NULL,
[Bids] INT NULL,
[Clicks] INT NULL,
[Companion Clicks] INT NULL,
[Companion Impressions] INT NULL,
[Data Cost (Adv Currency)] DECIMAL(37,15) NULL,
[Data Cost (Partner Currency)] DECIMAL(37,15) NULL,
[Data Cost (USD)] DECIMAL(37,15) NULL,
[Fee Features Cost (Adv Currency)] DECIMAL(37,15) NULL,
[Fee Features Cost (Partner Currency)] DECIMAL(37,15) NULL,
[Fee Features Cost (USD)] DECIMAL(37,15) NULL,
[IAS Display Fully In View 0 Seconds] INT NULL,
[IAS Display Fully In View 1 Second] INT NULL,
[IAS Display Fully In View 15 Seconds] INT NULL,
[IAS Display Fully In View 5 Seconds] INT NULL,
[IAS Display In View 1 Second] INT NULL,
[IAS Display In View 15 Seconds] INT NULL,
[IAS Display In View 5 Seconds] INT NULL,
[IAS High Risk Impression Count] INT NULL,
[IAS Low Risk Impression Count] INT NULL,
[IAS Moderate Risk Impression Count] INT NULL,
[IAS Non GVIT Impression Count] INT NULL,
[IAS Suspicious Activity] INT NULL,
[IAS Total Impression Count] INT NULL,
[IAS Very High Risk Impression Count] INT NULL,
[IAS Video 25% Complete] INT NULL,
[IAS Video 50% Complete] INT NULL,
[IAS Video 75% Complete] INT NULL,
[IAS Video Completed Views] INT NULL,
[IAS Video Muted] INT NULL,
[IAS Video Viewable 25% Complete] INT NULL,
[IAS Video Viewable 50% Complete] INT NULL,
[IAS Video Viewable 75% Complete] INT NULL,
[IAS Video Viewable Completed Views] INT NULL,
[Impressions] INT NULL,
[In-banner Player Impressions] INT NULL,
[Large Player Impressions] INT NULL,
[Media Cost (Adv Currency)] DECIMAL(37,15) NULL,
[Media Cost (Partner Currency)] DECIMAL(37,15) NULL,
[Media Cost (USD)] DECIMAL(37,15) NULL,
[Medium Player Impressions] INT NULL,
[MOAT Display In View Time 10 Seconds] INT NULL,
[MOAT Display In View Time 15 Seconds] INT NULL,
[MOAT Display In View Time 30 Seconds] INT NULL,
[MOAT Display In View Time 5 Seconds] INT NULL,
[MOAT Display On Screen] INT NULL,
[MOAT Display Universal Interaction] INT NULL,
[MOAT Display Universal Interaction Time 10 Seconds] INT NULL,
[MOAT Display Universal Interaction Time 15 Seconds] INT NULL,
[MOAT Display Universal Interaction Time 30 Seconds] INT NULL,
[MOAT Display Universal Interaction Time 5 Seconds] INT NULL,
[MOAT Video Audible and Visible on Complete] INT NULL,
[MOAT Video In View Time 3 Seconds] INT NULL,
[MOAT Video In View Time 5 Seconds] INT NULL,
[MOAT Video Visible on Complete] INT NULL,
[Non-USD Currency Cost (Adv Currency)] DECIMAL(37,15) NULL,
[Non-USD Currency Cost (Partner Currency)] DECIMAL(37,15) NULL,
[Non-USD Currency Cost (USD)] DECIMAL(37,15) NULL,
[Partner Cost (Adv Currency)] DECIMAL(37,15) NULL,
[Partner Cost (Partner Currency)] DECIMAL(37,15) NULL,
[Partner Cost (USD)] DECIMAL(37,15) NULL,
[Player 25% Complete] INT NULL,
[Player 50% Complete] INT NULL,
[Player 75% Complete] INT NULL,
[Player Audible Event] INT NULL,
[Player Close] INT NULL,
[Player Collapse] INT NULL,
[Player Completed Views] INT NULL,
[Player Engaged Views] INT NULL,
[Player Errors] INT NULL,
[Player Expansion] INT NULL,
[Player Full Screen] INT NULL,
[Player Invitation Accept] INT NULL,
[Player Mute] INT NULL,
[Player Pause] INT NULL,
[Player Playing Event] INT NULL,
[Player Resume] INT NULL,
[Player Rewind] INT NULL,
[Player Skip] INT NULL,
[Player Starts] INT NULL,
[Player Total Playing Seconds] INT NULL,
[Player Unmute] INT NULL,
[Player Views] INT NULL,
[Predictive Clearing Savings (Adv Currency)] DECIMAL(37,15) NULL,
[Predictive Clearing Savings (Partner Currency)] DECIMAL(37,15) NULL,
[Predictive Clearing Savings (USD)] DECIMAL(37,15) NULL,
[Profit (Adv Currency)] DECIMAL(37,15) NULL,
[Profit (Partner Currency)] DECIMAL(37,15) NULL,
[Profit (USD)] DECIMAL(37,15) NULL,
[Sampled Tracked Impressions] INT NULL,
[Sampled Viewed Impressions] INT NULL,
[Small Player Impressions] INT NULL,
[Total Audible Seconds] INT NULL,
[Total Bid Amount (Adv Currency)] DECIMAL(37,15) NULL,
[Total Bid Amount (Partner Currency)] DECIMAL(37,15) NULL,
[Total Bid Amount (USD)] DECIMAL(37,15) NULL,
[Total Custom CPA Conversions] INT NULL,
[Total Seconds In View] INT NULL,
[TTD Cost (Adv Currency)] DECIMAL(37,15) NULL,
[TTD Cost (Partner Currency)] DECIMAL(37,15) NULL,
[TTD Cost (USD)] DECIMAL(37,15) NULL,
[TTD Margin (Adv Currency)] DECIMAL(37,15) NULL,
[TTD Margin (Partner Currency)] DECIMAL(37,15) NULL,
[TTD Margin (USD)] DECIMAL(37,15) NULL,
[Video In View Event] INT NULL,
[White Ops SIVT Bids Avoided] INT NULL,
[CreatedOn] DATETIME2 NULL CONSTRAINT df_Staging_TdDailyPerformance_CreatedOn DEFAULT SYSUTCDATETIME(),
[ModifiedOn] DATETIME2 NULL CONSTRAINT df_Staging_TdDailyPerformance_ModifiedOn DEFAULT SYSUTCDATETIME(),
[Retired] BIT NULL CONSTRAINT df_Staging_TdDailyPerformance_Retired DEFAULT 0
)
IdMatch.TdDailyPerformance
CREATE TABLE [IdMatch].[TdDailyPerformance]
(
[ID] INT IDENTITY(1,1) NOT NULL,
[HashCode] BINARY(65) NOT NULL,
[Ad Environment] NVARCHAR(1024) NULL,
[Ad Format] NVARCHAR(10) NULL,
[Ad Group] NVARCHAR(1024) NULL,
[Ad Group ID] NVARCHAR(32) NULL,
[Ad Group Integer ID] INT NULL,
[Ad Server Creative Placement ID] NVARCHAR(1024) NULL,
[Ad Server Name] NVARCHAR(1024) NULL,
[Advertiser] NVARCHAR(1024) NULL,
[Advertiser Currency Code] NVARCHAR(1024) NULL,
[Advertiser ID] NVARCHAR(32) NULL,
[App] NVARCHAR(1024) NULL,
[Browser] NVARCHAR(30) NULL,
[Campaign] NVARCHAR(1024) NULL,
[Campaign ID] NVARCHAR(32) NULL,
[Carrier ID] INT NULL,
[Carrier Name] NVARCHAR(1024) NULL,
[Category ID] NVARCHAR(1024) NULL,
[Category Name] NVARCHAR(1024) NULL,
[City] NVARCHAR(50) NULL,
[Country] NVARCHAR(50) NULL,
[Creative] NVARCHAR(1024) NULL,
[Creative Duration In Seconds] INT NULL,
[Creative ID] NVARCHAR(32) NULL,
[Date] NVARCHAR(1024) NULL,
[Device Make] NVARCHAR(32) NULL,
[Device Type] NVARCHAR(15) NULL,
[Fold] NVARCHAR(128) NULL,
[Language] NVARCHAR(1024) NULL,
[Market Type] NVARCHAR(32) NULL,
[Media Type] NVARCHAR(32) NULL,
[Metro] NVARCHAR(128) NULL,
[Metro Code] INT NULL,
[Operating System] NVARCHAR(32) NULL,
[Operating System Family] NVARCHAR(1024) NULL,
[Partner ID] NVARCHAR(32) NULL,
[Partner Name] NVARCHAR(32) NULL,
[Region] NVARCHAR(128) NULL,
[Site] NVARCHAR(128) NULL,
[Site List Name] NVARCHAR(1024) NULL,
[Site/Category Bid Factor] NVARCHAR(1024) NULL,
[Supply Vendor] NVARCHAR(25) NULL,
[Supply Vendor Integer ID] INT NULL,
[Supply Vendor Publisher Id] NVARCHAR(64) NULL,
[Timezone] NVARCHAR(1024) NULL,
[Video Playback Type] NVARCHAR(32) NULL,
[Whitelist Site] NVARCHAR(32) NULL,
[CreatedOn] DATETIME2 NOT NULL CONSTRAINT df_IdMatch_TdDailyPerformance_CreatedOn DEFAULT SYSUTCDATETIME(),
[ModifiedOn] DATETIME2 NOT NULL CONSTRAINT df_IdMatch_TdDailyPerformance_ModifiedOn DEFAULT SYSUTCDATETIME(),
[Retired] BIT NOT NULL CONSTRAINT df_IdMatch_TdDailyPerformance_Retired DEFAULT 0
)
GO