-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Performance: Reduce number of database calls in save and publish operations #20485
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f52677b
Added request caching to media picker media retrieval, to improve per…
AndyButland c1f9e80
WIP: Update or insert in bulk when updating property data.
AndyButland 0074807
Add tests verifying UpdateBatch.
AndyButland f71bd77
Fixed issue with UpdateBatch and SQL Server.
AndyButland 78ddec5
Removed stopwatch.
AndyButland ddac955
Fix test on SQLite (failing on SQLServer).
AndyButland 1f0e4a7
Added temporary test for direct call to NPoco UpdateBatch.
AndyButland 7c6916e
Fixed test on SQLServer.
AndyButland 67b5219
Add integration test verifying the same property data is persisted as…
AndyButland d7f7e03
Merge branch 'main' into v16/hotfix/cache-media-requests-during-save
AndyButland e579068
Log expected warning in DocumentUrlService as debug.
AndyButland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
...mbraco.Tests.Integration/Umbraco.Infrastructure/Persistence/NPocoTests/NPocoFetchTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
....Tests.Integration/Umbraco.Infrastructure/Persistence/NPocoTests/NPocoUpdateBatchTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| // Copyright (c) Umbraco. | ||
| // See LICENSE for more details. | ||
|
|
||
| using NPoco; | ||
| using NUnit.Framework; | ||
| using Umbraco.Cms.Infrastructure.Persistence.Dtos; | ||
| using Umbraco.Cms.Tests.Common.Testing; | ||
| using Umbraco.Cms.Tests.Integration.Testing; | ||
|
|
||
| namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence.NPocoTests; | ||
|
|
||
| [TestFixture] | ||
| [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)] | ||
| internal sealed class NPocoUpdateBatchTests : UmbracoIntegrationTest | ||
| { | ||
| [Test] | ||
| public void Can_Update_Batch() | ||
| { | ||
| // Arrange | ||
| var servers = new List<ServerRegistrationDto>(); | ||
| for (var i = 0; i < 3; i++) | ||
| { | ||
| servers.Add(new ServerRegistrationDto | ||
| { | ||
| Id = i + 1, | ||
| ServerAddress = "address" + i, | ||
| ServerIdentity = "computer" + i, | ||
| DateRegistered = DateTime.Now, | ||
| IsActive = false, | ||
| DateAccessed = DateTime.Now, | ||
| }); | ||
| } | ||
|
|
||
| using (var scope = ScopeProvider.CreateScope()) | ||
| { | ||
| scope.Database.BulkInsertRecords(servers); | ||
| scope.Complete(); | ||
| } | ||
|
|
||
| // Act | ||
| for (var i = 0; i < 3; i++) | ||
| { | ||
| servers[i].ServerAddress = "newaddress" + i; | ||
| servers[i].IsActive = true; | ||
| } | ||
|
|
||
| using (var scope = ScopeProvider.CreateScope()) | ||
| { | ||
| var updateBatch = servers | ||
| .Select(x => UpdateBatch.For(x)) | ||
| .ToList(); | ||
| var updated = scope.Database.UpdateBatch(updateBatch, new BatchOptions { BatchSize = 100 }); | ||
| Assert.AreEqual(3, updated); | ||
| scope.Complete(); | ||
| } | ||
|
|
||
| // Assert | ||
| using (var scope = ScopeProvider.CreateScope()) | ||
| { | ||
| var dtos = scope.Database.Fetch<ServerRegistrationDto>(); | ||
| Assert.AreEqual(3, dtos.Count); | ||
| for (var i = 0; i < 3; i++) | ||
| { | ||
| Assert.AreEqual(servers[i].ServerAddress, dtos[i].ServerAddress); | ||
| Assert.AreEqual(servers[i].ServerIdentity, dtos[i].ServerIdentity); | ||
| Assert.AreEqual(servers[i].IsActive, dtos[i].IsActive); | ||
| } | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.