MS Access查询优化问题

时间:2013-02-12 05:39:33

标签: sql ms-access

我想在查询下运行以获取我所追求的结果集。但即使使用索引

也需要很长时间

然后我将查询分成了每组。那个案子更好。但是我以后必须添加两个连接键。然后它没有给出结果。 (长时间运行)

只想知道是否有可能一次性运行所有群组的查询

SELECT DISTINCT T_Extract.[SerGrp], T_Extract.[SerCat], T_Extract.[Component Description (Product)], T_Extract.[Mod_Item ID],
     " ##" AS IM, IM_Mapping.TrfCode, IM_Mapping.CatCode, IM_Mapping.CatDescr, IM_Mapping.SubCatCode, IM_Mapping.SubCatDescr, 
    LKP_Item.Group, LKP_Item.[Modality Source]
    FROM ((LKP_Product 
            INNER JOIN IM_Mapping ON (LKP_Product.State=IM_Mapping.StateCode) AND (LKP_Product.OptCode=IM_Mapping.OptCode)) 
                INNER JOIN T_Extract ON LKP_Product.[Component Description (Product)]=T_Extract.[Component Description (Product)]) 
                    INNER JOIN LKP_Item ON (T_Extract.[Mod_Item ID]=LKP_Item.[Item ID]) AND (IM_Mapping.TrfCode=LKP_Item.[iMed TrfCode])
                                    AND (IM_Mapping.PubNum = LKP_Item.PubNum) AND (IM_Mapping.PracType = LKP_Item.PracType)
    WHERE (((T_Extract.[SerGrp])<>[CatDescr]) 
    AND ((T_Extract.[SerCat])<>[SubCatDescr]) 
    AND ((LKP_Item.Group)="B1"));

我在下面的列

上创建了索引
LKP_Item.PubNum
LKP_Item.PracType
LKP_Item.[Item ID]
LKP_Item.[iMed TrfCode]
LKP_Item.Group


LKP_Product.State
LKP_Product.OptCode
LKP_Product.[Component Description (Product)]


IM_Mapping.StateCode
IM_Mapping.OptCode
IM_Mapping.PubNum
IM_Mapping.PracType
IM_Mapping.[CatDescr]
IM_Mapping.[SubCatDescr]


T_Extract.[Component Description (Product)]
T_Extract.[Mod_Item ID]
T_Extract.[SerCat]
T_Extract.[SerGrp]

即使我在LKP_items和IM_Mapping(practype&amp; pubnum)之间添加了另外两个连接列之后我们以组方式运行,但是仍然运行了30分钟的查询而没有任何结果

干杯

Shabar

0 个答案:

没有答案