Path: redb/redb.Tests.Integration/Tests/MsSqlPro/MsSqlProArrayContainsFoldTests.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/MsSqlPro/MsSqlProArrayContainsFoldTests.cs ---- using System.Text.RegularExpressions; using redb.Tests.Integration.Fixtures; using redb.Tests.Integration.Models; namespace redb.Tests.Integration.Tests.MsSqlPro; /// /// An OR of several Contains over one array reads the elements once, with the values in a list: one EXISTS with IN, not /// one EXISTS per value (E169: 260 -> 140 ms). The answers are held equal to the other form by /// PvtPrefilterEquivalenceTestsBase; this pins the shape of the statement with the planner on. /// [Collection("MsSqlPro")] public class MsSqlProArrayContainsFoldTests { private readonly redb.Core.IRedbService _redb; public MsSqlProArrayContainsFoldTests(MsSqlProFixture fixture) => _redb = fixture.Redb; [Fact] public async Task OrOfContainsOverOneArray_IsOneExistsWithTheValuesInAList() { var restore = _redb.Configuration.EnablePvtPrefilter; try { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = true); var sql = await _redb.Query() .Where(e => e.Skills != null && (e.Skills.Contains("C#") || e.Skills.Contains("Python") || e.Skills.Contains("SQL"))) .Take(100) .ToSqlStringAsync(); Regex.Matches(sql, @"_array_index IS NOT NULL AND a\._\w+ = ").Count.Should().Be(0, "no EXISTS per value:\n{0}", sql); Regex.Matches(sql, @"_array_index IS NOT NULL AND a\._\w+ IN \(").Count.Should().Be(1, "one read of the elements:\n{0}", sql); } finally { _redb.UpdateConfiguration(c => c.EnablePvtPrefilter = restore); } } }