在使用具有多个范围的映射表时,我遇到了性能问题。映射表的布局如下。
ResultNumber param1Min param1Max param2Min param2Max ... param8min param8max
这些是映射表的列名。桌子上连接的是param1, param2, param3 ... param8
.
我需要找到(param1 在 param1Min 和 param1Max 之间)和(param2 在 param2Min 和 param2Max 之间)的行......并从匹配的行中获取结果编号。问题是映射表有超过 200 万行,我无法索引该表,因为它必须使用范围来查找所需的内容。
关于如何加快速度的任何想法?
我还包括了我尝试过的完全没有帮助的索引
SELECT ResultNumber
FROM MappingTable
WHERE ( param1 BETWEEN param1Min AND param1Max )
AND ( param2 BETWEEN param2Min AND param2Max )
AND ( param3 BETWEEN param3Min AND param3Max )
...
CREATE CLUSTERED INDEX [index] ON [dbo].MappingTable
(
[param1Min] ASC,
[param1Max] ASC,
[param2Min] ASC,
[param2Max] ASC,
[param3Min] ASC,
[param3Max] ASC,
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)