简体   繁体   English

CRM 2011 EmailHashBase

[英]CRM 2011 EmailHashBase

I have just upgraded to CRM 2011 from 4.0, and I'm seeing a lot of errors in the application log, I think owing to the email router. 我刚刚从4.0升级到CRM 2011,由于电子邮件路由器,我在应用程序日志中看到很多错误。 The error text is "Query execution time of 30.0 seconds exceeded the threshold of 10 seconds". 错误文本为“ 30.0秒的查询执行时间超过10秒的阈值”。

Here's the query it's executing: 这是它正在执行的查询:

WITH Candidates
        (
            ActivityId
        ) AS
        (SELECT  ActivityId
        FROM     EmailHashBase WITH (NOLOCK)
        WHERE    ActivityId IN
                (SELECT  ActivityId
                FROM     EmailHashBase WITH (NOLOCK)
                WHERE    HashType = 0
                    AND Hash IN (111682,1892164739,45,1824023892,54,3805,125879)
                GROUP BY ActivityId
                HAVING   COUNT(ActivityId) >= 7
                )
            AND HashType = 1
            AND Hash IN (969105075,1418975348,547970098,1044570065,-1578559672,1137188287,-1492206818,1365121987,1893861533,-1313312639,-1829169632,-1685403462,-518982188,1123523219,284291011,-981044541,1790111815,-808308608,-599769785,971845046)
        GROUP BY ActivityId
        HAVING   COUNT(ActivityId) >= 2
        )
SELECT   TOP 1 a.ActivityId
FROM     ActivityPointerBase AS a WITH (NOLOCK)
WHERE    a.ActivityId IN
            (SELECT ActivityId
            FROM    Candidates AS c
            WHERE(
                    (SELECT COUNT(*)
                            FROM    EmailHashBase AS h
                            WHERE   h.ActivityId = c.ActivityId
                                AND h.HashType   = 0
                    )
                    <= 7
                ) 
            )
ORDER BY a.ModifiedOn DESC

Running this query directly against the database takes up to a minute. 直接对数据库运行此查询最多需要一分钟。 I've run it using "Set Statistics IO ON" and have following results: 我已经使用“ Set Statistics IO ON”运行了它,并得到以下结果:

Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'EmailHashBase'. Scan count 17696074, logical reads 53155625, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table 'ActivityPointerBase'. Scan count 1, logical reads 5060, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.

SQL Server Execution Times:
CPU time = 36567 ms,  elapsed time = 36562 ms.

Obviously there's a problem with EmailHashBase. 显然,EmailHashBase存在问题。 I've added a non-clustered index on the Hash column and rebuilt the indexes, but I'm still getting a high scan and logical read count. 我在Hash列上添加了非聚集索引并重建了索引,但是我仍然获得较高的扫描和逻辑读取计数。

I cannot change the query. 我无法更改查询。

Any suggestions on what I can do to the table to fix this? 关于如何解决此问题,我有什么建议吗?

Turns out an index had been created by the database tuning adviser that caused the delay. 事实证明,数据库调整顾问已创建了导致延迟的索引。 Deleting the index has resolved the issue. 删除索引已解决了该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM