mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 19:59:54 -05:00
Merged PR 1659003: [Composite OpClass] Enable Runtime Functions and add test coverage
### Does this PR have any customer impact? No ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Feature/POC ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) No ### Are you introducing any new config? If yes, do you have tests with and without them being set? Yes ### ChangeLog (Refer [Template](../oss/CHANGELOG.md)) ### Description Fix up runtime index recheck function support to reduce loading documents. This should reduce the number of runtime rechecks that are needed for documents and trust the index more as we will evaluate these clauses directly on the index first. Also add option to trigger jstest coverage for the new opclass - and set them to run on the MX jstests - this is still disabled right now since there are some failing tests but will be enabled separately. ---- #### AI description (iteration 1) #### PR Classification New feature: This pull request introduces runtime functions for composite index operations and enhances test coverage. #### PR Summary This pull request enables runtime functions for composite index operations, improving the flexibility and efficiency of index handling. It also adds test coverage to ensure the reliability of these new features. - `bson_gin_composite_entrypoint.c`: Refactored comparison logic to support runtime functions for index rechecks. - `bson_gin_composite_core.c`: Implemented `IsValidForIndexValue` function to handle various BSON index strategies with runtime rechecks. - `create_indexes.c`: Modified index creation logic to conditionally enable new composite index opclass based on configuration. - `bson_gin_composite_private.h`: Added `IndexRecheckArgs` structure to support runtime recheck strategies. - `testing_configs.c`: Introduced configuration options for enabling the new composite index opclass by default. <!-- GitOpsUserAgent=GitOps.Apps.Server.pullrequestcopilot -->
This commit is contained in:
1 parent
535e5713ba
commit
efa2b802f6
13 files changed
+647
-166
No files matched your search
+8
-8
@@ -591,9 +591,9 @@ EXPLAIN (COSTS OFF, ANALYZE ON, SUMMARY OFF, TIMING OFF) SELECT object_id, docum
|
||||
Node: host=localhost port=58070 dbname=regression
|
||||
-> Bitmap Heap Scan on documents_1200_1200005 collection (actual rows=19 loops=1)
|
||||
Recheck Cond: (document OPERATOR(documentdb_api_catalog.@!=) '{ "a.b" : { "$numberInt" : "1" } }'::documentdb_core.bson)
|
||||
Rows Removed by Index Recheck: 4
|
||||
Rows Removed by Index Recheck: 3
|
||||
Heap Blocks: exact=1
|
||||
-> Bitmap Index Scan on queryoperator_ab (actual rows=23 loops=1)
|
||||
-> Bitmap Index Scan on queryoperator_ab (actual rows=22 loops=1)
|
||||
Index Cond: (document OPERATOR(documentdb_api_catalog.@!=) '{ "a.b" : { "$numberInt" : "1" } }'::documentdb_core.bson)
|
||||
(13 rows)
|
||||
|
||||
@@ -985,9 +985,9 @@ EXPLAIN (COSTS OFF, ANALYZE ON, SUMMARY OFF, TIMING OFF) SELECT object_id, docum
|
||||
Node: host=localhost port=58070 dbname=regression
|
||||
-> Bitmap Heap Scan on documents_1200_1200005 collection (actual rows=21 loops=1)
|
||||
Recheck Cond: (document OPERATOR(documentdb_api_catalog.@!=) '{ "a" : { "b" : { "$numberInt" : "1" } } }'::documentdb_core.bson)
|
||||
Rows Removed by Index Recheck: 2
|
||||
Rows Removed by Index Recheck: 1
|
||||
Heap Blocks: exact=1
|
||||
-> Bitmap Index Scan on queryoperator_b_a (actual rows=23 loops=1)
|
||||
-> Bitmap Index Scan on queryoperator_b_a (actual rows=22 loops=1)
|
||||
Index Cond: (document OPERATOR(documentdb_api_catalog.@!=) '{ "a" : { "b" : { "$numberInt" : "1" } } }'::documentdb_core.bson)
|
||||
(13 rows)
|
||||
|
||||
@@ -1273,9 +1273,9 @@ EXPLAIN (COSTS OFF, ANALYZE ON, SUMMARY OFF, TIMING OFF) SELECT object_id, docum
|
||||
Sort Method: quicksort Memory: 25kB
|
||||
-> Bitmap Heap Scan on documents_1200_1200005 collection (actual rows=2 loops=1)
|
||||
Recheck Cond: (document OPERATOR(documentdb_api_catalog.@&=) '{ "a" : [ { "$elemMatch" : { "b" : "M", "c" : { "$gt" : { "$numberInt" : "50" } } } }, { "$elemMatch" : { "c" : { "$numberInt" : "100" }, "d" : "Y" } } ] }'::documentdb_core.bson)
|
||||
Rows Removed by Index Recheck: 9
|
||||
Rows Removed by Index Recheck: 1
|
||||
Heap Blocks: exact=1
|
||||
-> Bitmap Index Scan on queryoperator_b_a (actual rows=11 loops=1)
|
||||
-> Bitmap Index Scan on queryoperator_b_a (actual rows=3 loops=1)
|
||||
Index Cond: (document OPERATOR(documentdb_api_catalog.@&=) '{ "a" : [ { "$elemMatch" : { "b" : "M", "c" : { "$gt" : { "$numberInt" : "50" } } } }, { "$elemMatch" : { "c" : { "$numberInt" : "100" }, "d" : "Y" } } ] }'::documentdb_core.bson)
|
||||
(16 rows)
|
||||
|
||||
@@ -1588,9 +1588,9 @@ EXPLAIN (COSTS OFF, ANALYZE ON, SUMMARY OFF, TIMING OFF) SELECT object_id, docum
|
||||
Sort Method: quicksort Memory: 27kB
|
||||
-> Bitmap Heap Scan on documents_1200_1200005 collection (actual rows=21 loops=1)
|
||||
Recheck Cond: (document OPERATOR(documentdb_api_catalog.@!=) '{ "a" : { "$numberInt" : "1" } }'::documentdb_core.bson)
|
||||
Rows Removed by Index Recheck: 2
|
||||
Rows Removed by Index Recheck: 1
|
||||
Heap Blocks: exact=1
|
||||
-> Bitmap Index Scan on queryoperator_b_a (actual rows=23 loops=1)
|
||||
-> Bitmap Index Scan on queryoperator_b_a (actual rows=22 loops=1)
|
||||
Index Cond: (document OPERATOR(documentdb_api_catalog.@!=) '{ "a" : { "$numberInt" : "1" } }'::documentdb_core.bson)
|
||||
(16 rows)
|
||||
|
||||
|
||||
+8
-8
@@ -592,9 +592,9 @@ EXPLAIN (COSTS OFF, ANALYZE ON, SUMMARY OFF, TIMING OFF) SELECT object_id, docum
|
||||
Node: host=localhost port=58070 dbname=regression
|
||||
-> Bitmap Heap Scan on documents_1200_1200005 collection (actual rows=19 loops=1)
|
||||
Recheck Cond: (document OPERATOR(documentdb_api_catalog.@!=) '{ "a.b" : { "$numberInt" : "1" } }'::documentdb_core.bson)
|
||||
Rows Removed by Index Recheck: 4
|
||||
Rows Removed by Index Recheck: 3
|
||||
Heap Blocks: exact=1
|
||||
-> Bitmap Index Scan on queryoperator_ab (actual rows=23 loops=1)
|
||||
-> Bitmap Index Scan on queryoperator_ab (actual rows=22 loops=1)
|
||||
Index Cond: (document OPERATOR(documentdb_api_catalog.@!=) '{ "a.b" : { "$numberInt" : "1" } }'::documentdb_core.bson)
|
||||
(13 rows)
|
||||
|
||||
@@ -986,9 +986,9 @@ EXPLAIN (COSTS OFF, ANALYZE ON, SUMMARY OFF, TIMING OFF) SELECT object_id, docum
|
||||
Node: host=localhost port=58070 dbname=regression
|
||||
-> Bitmap Heap Scan on documents_1200_1200005 collection (actual rows=21 loops=1)
|
||||
Recheck Cond: (document OPERATOR(documentdb_api_catalog.@!=) '{ "a" : { "b" : { "$numberInt" : "1" } } }'::documentdb_core.bson)
|
||||
Rows Removed by Index Recheck: 2
|
||||
Rows Removed by Index Recheck: 1
|
||||
Heap Blocks: exact=1
|
||||
-> Bitmap Index Scan on queryoperator_b_a (actual rows=23 loops=1)
|
||||
-> Bitmap Index Scan on queryoperator_b_a (actual rows=22 loops=1)
|
||||
Index Cond: (document OPERATOR(documentdb_api_catalog.@!=) '{ "a" : { "b" : { "$numberInt" : "1" } } }'::documentdb_core.bson)
|
||||
(13 rows)
|
||||
|
||||
@@ -1267,9 +1267,9 @@ EXPLAIN (COSTS OFF, ANALYZE ON, SUMMARY OFF, TIMING OFF) SELECT object_id, docum
|
||||
Sort Method: quicksort Memory: 25kB
|
||||
-> Bitmap Heap Scan on documents_1200_1200005 collection (actual rows=2 loops=1)
|
||||
Recheck Cond: (document OPERATOR(documentdb_api_catalog.@&=) '{ "a" : [ { "$elemMatch" : { "b" : "M", "c" : { "$gt" : { "$numberInt" : "50" } } } }, { "$elemMatch" : { "c" : { "$numberInt" : "100" }, "d" : "Y" } } ] }'::documentdb_core.bson)
|
||||
Rows Removed by Index Recheck: 9
|
||||
Rows Removed by Index Recheck: 1
|
||||
Heap Blocks: exact=1
|
||||
-> Bitmap Index Scan on queryoperator_b_a (actual rows=11 loops=1)
|
||||
-> Bitmap Index Scan on queryoperator_b_a (actual rows=3 loops=1)
|
||||
Index Cond: (document OPERATOR(documentdb_api_catalog.@&=) '{ "a" : [ { "$elemMatch" : { "b" : "M", "c" : { "$gt" : { "$numberInt" : "50" } } } }, { "$elemMatch" : { "c" : { "$numberInt" : "100" }, "d" : "Y" } } ] }'::documentdb_core.bson)
|
||||
(16 rows)
|
||||
|
||||
@@ -1582,9 +1582,9 @@ EXPLAIN (COSTS OFF, ANALYZE ON, SUMMARY OFF, TIMING OFF) SELECT object_id, docum
|
||||
Sort Method: quicksort Memory: 27kB
|
||||
-> Bitmap Heap Scan on documents_1200_1200005 collection (actual rows=21 loops=1)
|
||||
Recheck Cond: (document OPERATOR(documentdb_api_catalog.@!=) '{ "a" : { "$numberInt" : "1" } }'::documentdb_core.bson)
|
||||
Rows Removed by Index Recheck: 2
|
||||
Rows Removed by Index Recheck: 1
|
||||
Heap Blocks: exact=1
|
||||
-> Bitmap Index Scan on queryoperator_b_a (actual rows=23 loops=1)
|
||||
-> Bitmap Index Scan on queryoperator_b_a (actual rows=22 loops=1)
|
||||
Index Cond: (document OPERATOR(documentdb_api_catalog.@!=) '{ "a" : { "$numberInt" : "1" } }'::documentdb_core.bson)
|
||||
(16 rows)
|
||||
|
||||
|
||||
+4
-4
@@ -1724,7 +1724,7 @@ DEBUG: Commiting intermediate state and reacquiring collection lock
|
||||
(1 row)
|
||||
|
||||
-- should have updated 10 times
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch');
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch') ORDER BY object_id;
|
||||
document
|
||||
---------------------------------------------------------------------
|
||||
{ "_id" : { "$numberInt" : "1" }, "a" : { "$numberInt" : "1" }, "b" : { "$numberInt" : "11" } }
|
||||
@@ -1771,7 +1771,7 @@ DEBUG: Commiting intermediate state and reacquiring collection lock
|
||||
(1 row)
|
||||
|
||||
-- still increments
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch');
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch') ORDER BY object_id;
|
||||
document
|
||||
---------------------------------------------------------------------
|
||||
{ "_id" : { "$numberInt" : "1" }, "a" : { "$numberInt" : "1" }, "b" : { "$numberInt" : "21" } }
|
||||
@@ -1817,7 +1817,7 @@ DEBUG: Commiting intermediate state and reacquiring collection lock
|
||||
(1 row)
|
||||
|
||||
-- still increments
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch');
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch') ORDER BY object_id;
|
||||
document
|
||||
---------------------------------------------------------------------
|
||||
{ "_id" : { "$numberInt" : "1" }, "a" : { "$numberInt" : "1" }, "b" : { "$numberInt" : "31" } }
|
||||
@@ -1864,7 +1864,7 @@ DEBUG: executing " SELECT documentdb_api_internal.update_worker($1, $2, $3, $4:
|
||||
(1 row)
|
||||
|
||||
-- still increments
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch');
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch') ORDER BY object_id;
|
||||
document
|
||||
---------------------------------------------------------------------
|
||||
{ "_id" : { "$numberInt" : "1" }, "a" : { "$numberInt" : "1" }, "b" : { "$numberInt" : "41" } }
|
||||
|
||||
@@ -684,7 +684,7 @@ CALL documentdb_api.update_bulk('update_bulk', :'update_query2');
|
||||
CALL documentdb_api.update_bulk('update_bulk', :'update_query3');
|
||||
|
||||
-- should have updated 10 times
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch');
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch') ORDER BY object_id;
|
||||
|
||||
-- reduce batch to 8
|
||||
set documentdb.batchWriteSubTransactionCount to 8;
|
||||
@@ -699,7 +699,7 @@ CALL documentdb_api.update_bulk('update_bulk', :'update_query2');
|
||||
CALL documentdb_api.update_bulk('update_bulk', :'update_query3');
|
||||
|
||||
-- still increments
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch');
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch') ORDER BY object_id;
|
||||
|
||||
-- now reduce to 3
|
||||
set documentdb.batchWriteSubTransactionCount to 3;
|
||||
@@ -714,7 +714,7 @@ CALL documentdb_api.update_bulk('update_bulk', :'update_query2');
|
||||
CALL documentdb_api.update_bulk('update_bulk', :'update_query3');
|
||||
|
||||
-- still increments
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch');
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch') ORDER BY object_id;
|
||||
|
||||
-- disable local writes
|
||||
set documentdb.useLocalExecutionShardQueries to off;
|
||||
@@ -725,4 +725,4 @@ CALL documentdb_api.update_bulk('update_bulk', :'update_query2');
|
||||
CALL documentdb_api.update_bulk('update_bulk', :'update_query3');
|
||||
|
||||
-- still increments
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch');
|
||||
SELECT document FROM documentdb_api.collection('update_bulk', 'test_update_batch') ORDER BY object_id;
|
||||
Reference in new issue
Block a user