-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add highly missing index: IX_CoreMessaging_MessageRecipient… #3474
Conversation
Please for all DNN Platform items do not include internal ESW tracking ticket numbers in the subject lines of Pull Requests and/or issues. This provides confusion to the community and others that they to reference these items that we do not have exposure to. |
@eugene-sea was it intentional to make this PR a work in progress or was that a mistake? |
@mitchelsellers, sorry, I was not acknowledged about these rules. |
@valadas, yes, it was intentional. When it will be ready for review I will mark the PR as such. |
FYI, the next version will be 9.5.0 so you might want to rename that file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer creating this as filtered index instead, it should be a unique index and using a more specific name, e.g. CoreMessaging_MessageRecipients_ForDispatch.
Second issue is vw_MessagesForDispatch, which contains 2 subqueries.
3rd issue is the use of subqueries in both sprocs, one using UserID as (non-unique)
4th the sprocs should just return the columns needed, not SELECT * FROM messages JOIN recipients.
@sleupold, I understand your points but let's not mix several problems together. The point of this PR is to add a highly missing index (it was reported by SQL Server). I have renamed the index as you suggested and made it as filtered (very good point). 2nd, 3rd, 4th issues do not affect the index. They are a separate problem. |
I am currently reviewing the process of messages for subscriptions in CoreMessaging and I this needs further investigation. When splitting the send process into chunks, significant complexity was added, which might cause issues on edge cases, we should review and maybe fix, before optimizing the resulting process. |
When do you plan to finish the review? |
@eugene-sea Do you have any detail of the size of the site/db that this recommendation was provided by SQL Server? I just want to make sure we have all of the facts before we add more DB Overhead. |
@mitchelsellers, Please keep in mind that the index is filtered by |
@eugene-sea |
@eugene-sea UPDATE {databaseOwner}[{objectQualifier}CoreMessaging_MessageRecipients] IF EXISTS (SELECT * FROM sys.indexes CREATE UNIQUE NONCLUSTERED INDEX [IX_{objectQualifier}CoreMessaging_MessageRecipients_ForDispatch] IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'{databaseOwner}[{objectQualifier}vw_MessagesForDispatch]')) CREATE VIEW {databaseOwner}[{objectQualifier}vw_MessagesForDispatch] IF EXISTS (SELECT * FROM sys.Procedures WHERE object_id = OBJECT_ID(N'{databaseOwner}[{objectQualifier}CoreMessaging_GetNextMessagesForInstantDispatch]')) CREATE PROCEDURE {databaseOwner}[{objectQualifier}CoreMessaging_GetNextMessagesForInstantDispatch]
/* alternative version: IF EXISTS (SELECT * FROM sys.Procedures WHERE object_id = OBJECT_ID(N'{databaseOwner}[{objectQualifier}CoreMessaging_GetNextMessagesForDigestDispatch]')) CREATE PROCEDURE [dbo].[CoreMessaging_GetNextMessagesForDigestDispatch]
END; -- Procedure |
@sleupold, in terms of performance it is fine, but |
@eugene-sea |
PS: IMO, another issue: |
@sleupold, sorry, I meant index should include MessageID, like: CREATE UNIQUE NONCLUSTERED INDEX [IX_{objectQualifier}CoreMessaging_MessageRecipients_ForDispatch]
ON {databaseOwner}[{objectQualifier}CoreMessaging_MessageRecipients]
([EmailSchedulerInstance], [UserID], [RecipientID])
INCLUDE ([LastModifiedOnDate], [MessageID]) ------> Added include here <----
WHERE [EmailSent] = 0
AND [Read] = 0
AND [Archived] = 0; |
@eugene-sea, |
is there a GitHub issue number associated? |
I have not created any GitHub issues for this PR. |
This PR has been superseded by #3540 (associated issue: #3539) |
…s_Read
Summary
CoreMessaging_GetNextMessagesForDigestDispatch
SP performance was improved by near 18x,CoreMessaging_GetNextMessagesForInstantDispatch
SP performance was improved by near 12x