Skip to content
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

[release/6.0] Microsoft.Data.Sqlite: Avoid re-sending PRAGMA key on pooled connections #29215

Merged
merged 1 commit into from
Oct 4, 2022

Conversation

bricelam
Copy link
Contributor

@bricelam bricelam commented Sep 27, 2022

Fixes #28967

Customer Impact

Connection pooling was designed to improve throughput in both high-traffic web scenarios and when using encryption. However, customers reported that when using encryption via SQLCipher, performance had not improved--it was still deriving the encryption key every time a connection was opened. This PR avoids that behavior and ensures the key is only derived once per pooled connection.

Regression?

No.

Risk

Low. This just moves the logic to a place where it will only be executed once per pooled connection instead of every time an ADO.NET connection is opened. The logic will continue to be skipped when not using encryption.

Verification

Manually verified the new perf characteristics. This simple benchmark goes from 5078 ms to 124.

using Dapper;
using Microsoft.Data.Sqlite;

using var connection = new SqliteConnection(
    "Data Source=test.db;Password=Password12!");

connection.Execute(
    "CREATE TABLE IF NOT EXISTS Data(Value)");

for (var i = 0; i < 10; i++)
{
    connection.Execute(
        "INSERT INTO Data VALUES (@Value)",
        new { Value = Random.Shared.Next() });
}

@bricelam bricelam requested a review from a team September 27, 2022 16:36
@bricelam bricelam added this to the 6.0.11 milestone Sep 27, 2022
@wtgodbe wtgodbe merged commit 5f0786a into dotnet:release/6.0 Oct 4, 2022
@ajcvickers ajcvickers removed this from the 6.0.11 milestone Oct 5, 2022
@bricelam bricelam deleted the key2 branch October 13, 2022 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants