Использование SQL Server 2016. У меня есть следующая таблица с большим количеством записей (30 мил +).
CREATE TABLE [dbo].[TABLE1]
(
[DATE_TIME] [DATETIME] NULL,
[TEXT] [VARCHAR](500) NULL,
[MSG] [VARCHAR](500) NULL,
[MSGID] [INT] NULL,
[SEVERITY] VARCHAR(50) NULL
)
CREATE NONCLUSTERED INDEX [TABLE1_IX1]
ON [dbo].[TABLE1] ([DATE_TIME] ASC, [MSGID] ASC, [SEVERITY] ASC)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,
SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
Следующий запрос очень медленный:
SELECT
[DATE_TIME], [TEXT], [MSG], [MSGID], [SEVERITY]
FROM
[TABLE1]
WHERE
FORMAT([DATE_TIME], 'yyyy-MM-dd') IN ('2019-06-25', '2019-06-24',etc.....)
AND [MSGID] IN (8016, 11, 3072, 23, 3062, etc....)
AND [SEVERITY] <> 'Medium'
ORDER BY
[DATE_TIME] DESC
Пожалуйста, помогите оптимизировать.