Path: redb/redb.Tests.Integration/Tests/MsSql/MsSqlSmallSaveTimingTests.cs Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/MsSql/MsSqlSmallSaveTimingTests.cs ---- using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Tests.Base; using Xunit.Abstractions; namespace redb.Tests.Integration.Tests.MsSql; [Collection("MsSql")] public class MsSqlSmallSaveTimingTests : SmallSaveTimingTestsBase { public MsSqlSmallSaveTimingTests(MsSqlFixture fixture, ITestOutputHelper output) : base(fixture.ServiceProvider, output) { } protected override string? PlanCacheReportSql => MsSqlPlanCache.InsertReport; } /// The cached plans of the insert statements of the current database (read only, needs VIEW SERVER STATE). internal static class MsSqlPlanCache { public const string InsertReport = """ SELECT s.Statement, COUNT(*) AS Plans, SUM(CAST(s.usecounts AS bigint)) AS Executions, LEFT(MIN(s.text), 400) AS Sample FROM ( SELECT CASE WHEN t.text LIKE '%INSERT INTO _values (_id, _id_structure%' THEN 'INSERT _values' WHEN t.text LIKE '%INSERT INTO _objects (_id, _id_parent%' THEN 'INSERT _objects' WHEN t.text LIKE '%insert bulk%' THEN 'insert bulk' END AS Statement, cp.usecounts, t.text FROM sys.dm_exec_cached_plans cp CROSS APPLY sys.dm_exec_sql_text(cp.plan_handle) t CROSS APPLY sys.dm_exec_plan_attributes(cp.plan_handle) pa WHERE pa.attribute = 'dbid' AND CAST(pa.value AS int) = DB_ID() AND t.text NOT LIKE '%dm_exec_cached_plans%' ) s WHERE s.Statement IS NOT NULL GROUP BY s.Statement """; }