-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
Bundle index deletions into a single DB request #310
Comments
Agreed. Introduced batching commands recently #228 but I assume I haven't done it for index deletions. |
Did a little testing with the profiler to see what's actually going on here. Focused on the index deletes, just for a simple command to profile. Batching isn't working. Which is then splitting them back out into multiple So for some numbers. For an update to two documents (which is what happens publishing on OrchardCore, with Versioning on). Locally the difference in adding extra indexes is marginal, but still expontential.
As soon as you put it on a remote sql server (azure), the time it takes simply to execute all these separate delete statements really starts to add up.
w/1000 indexes 28 seconds to execute all these commands. Now by taking @Piedone suggestion of wrapping them into a single So I think batching these into a more complex delete command (and applying the same thing to the other commands), something like a Now when testing this on Orchard Core, it's not just the delete's slowing the process, there are so so many But deletes could be a good place to start. |
Nice findings! As an example, in our particular app publishing the home page, a Page (the same content type as in the Blog recipe, with several widgets in it) issues 238 individual queries. Out of these, 190 are Furthermore, there are 19 Just saving a draft causes fewer queries, as expected, but still doing 141 (114 All this with 23 custom |
Shouldn't this be closed now? |
When one deletes a document all the index tables corresponding to the document type get a
DELETE
query. While these can be quite fast (since they use the primary key, many times there won't actually be a matching row, and some of the tables are small) they're issued one by one, incurring the penalty of the roundtrip to the DB (which might be a separate server reached over a network) many times. This can be a serious performance issue when you have a lot of indices (like >50).Instead of issuing these queries one by one, they could be bundle together into a single DB request (i.e. concatenated into a single query string). That way, the network roundtrip would only happen once.
Also see this Orchard issue: OrchardCMS/OrchardCore#7949
The text was updated successfully, but these errors were encountered: