Statistikker opdateres ikke automatisk, før statistikkerne er nødvendige igen. aka, TRUNCATE gør det ikke. Så "Nej".
Det oprindelige svar var "Ja", fordi det ikke er automatisk som en del af TRUNCATE. Det kommer an på, hvordan du læser spørgsmålet :-)
Husk, at statistik opdateres automatisk, når det er nødvendigt af en forespørgsel (f.eks. antal rækkeændringer). Fra "Indeksstatistik " i BOL
En måde at bekræfte ved at bruge STATS_DATE ...
SELECT
name AS index_name,
STATS_DATE(object_id, index_id)
FROM
sys.indexes
WHERE
object_id = OBJECT_ID('MyTruncatedTable')
Rediger :Jeg ville gerne være sikker :-)
Du vil se, at statistik kun opdateres af SELECT-sætningerne, ikke INSERT, DELETE eller TRUNCATE
IF OBJECT_ID('dbo.foo') IS NOT NULL DROP TABLE dbo.foo
CREATE TABLE dbo.foo (
bar int NOT NULL IDENTITY (1, 1) PRIMARY KEY,
thing int NOT NULL
)
CREATE INDEX IX_thing ON dbo.foo (thing)
INSERT dbo.foo (thing) SELECT c1.object_id FROM sys.columns c1, sys.columns c2
SELECT
name AS index_name,
STATS_DATE(object_id, index_id) AS AfterLoad
FROM sys.indexes WHERE object_id = OBJECT_ID('dbo.foo')
SELECT DISTINCT thing FROM dbo.foo ORDER BY thing DESC
SELECT
name AS index_name,
STATS_DATE(object_id, index_id) AS AfterFirstQuery
FROM sys.indexes WHERE object_id = OBJECT_ID('dbo.foo')
DELETE TOP (50000) dbo.foo
SELECT
name AS index_name,
STATS_DATE(object_id, index_id) AS AfterDelete
FROM sys.indexes WHERE object_id = OBJECT_ID('dbo.foo')
SELECT DISTINCT thing FROM dbo.foo ORDER BY thing DESC
SELECT
name AS index_name,
STATS_DATE(object_id, index_id) AS After2ndQuery
FROM sys.indexes WHERE object_id = OBJECT_ID('dbo.foo')
TRUNCATE TABLE dbo.foo
SELECT
name AS index_name,
STATS_DATE(object_id, index_id) AS AfterTruncate
FROM sys.indexes WHERE object_id = OBJECT_ID('dbo.foo')
SELECT DISTINCT thing FROM dbo.foo ORDER BY thing DESC
SELECT
name AS index_name,
STATS_DATE(object_id, index_id) AS After3rdQuery
FROM sys.indexes WHERE object_id = OBJECT_ID('dbo.foo')