You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend EXPLAIN and add config param to switch transformation of property filter (apache#1262)
* Add explain options
Explain command in the following format is supported
now:
`EXPLAIN (VERBOSE, COSTS OFF, FORMAT XML) ...`
Note that, this is basically Postgres' EXPLAIN command,
and the purpose of this is to support debugging and
regression tests.
* Add config param to switch transformation method of property filter
When the `age.enable_containment` parameter is on, the agtype
containment operator is used to transform property filter. When off,
access operator is used instead. The former case is preferable for
GIN index, and the later for BTREE expression index.
The idea of replacing containment with access operator in order to
support BTREE index is taken from a patch by Josh Innis.
A note on regression testing- although there are test cases for the
`age.enable_containment` parameter, sometimes it may be useful to
set this parameter before running any tests (not just the ones related
to it). For example, when the logic related to property transformation
changes. It can be set in the `age_regression.conf` file.
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Toronto'}]}) RETURN x $$) as (a agtype);
2463
+
count
2464
+
-------
2465
+
1
2466
+
(1 row)
2467
+
2468
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Toronto'}, {city: 'Vancouver'}]}) RETURN x $$) as (a agtype);
2469
+
count
2470
+
-------
2471
+
1
2472
+
(1 row)
2473
+
2474
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Alberta'}]}) RETURN x $$) as (a agtype);
2475
+
count
2476
+
-------
2477
+
0
2478
+
(1 row)
2479
+
2480
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {school:{program:{major:'Psyc'}}}) RETURN x $$) as (a agtype);
2481
+
count
2482
+
-------
2483
+
1
2484
+
(1 row)
2485
+
2486
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {name:'Bob',school:{program:{degree:'BSc'}}}) RETURN x $$) as (a agtype);
2487
+
count
2488
+
-------
2489
+
1
2490
+
(1 row)
2491
+
2492
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {school:{program:{major:'Cs'}}}) RETURN x $$) as (a agtype);
2493
+
count
2494
+
-------
2495
+
0
2496
+
(1 row)
2497
+
2498
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {name:'Bob',school:{program:{degree:'PHd'}}}) RETURN x $$) as (a agtype);
2499
+
count
2500
+
-------
2501
+
0
2502
+
(1 row)
2503
+
2504
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {phone:[987654321]}) RETURN x $$) as (a agtype);
2505
+
count
2506
+
-------
2507
+
1
2508
+
(1 row)
2509
+
2510
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {phone:[654765876]}) RETURN x $$) as (a agtype);
2511
+
count
2512
+
-------
2513
+
0
2514
+
(1 row)
2515
+
2516
+
SELECT * FROM cypher('test_enable_containment', $$ EXPLAIN (COSTS OFF) MATCH (x:Customer {school:{name:'XYZ',program:{degree:'BSc'}},phone:[987654321],parents:{}}) RETURN x $$) as (a agtype);
-- Previous set of queries, with enable_containment off
2524
+
SET age.enable_containment = off;
2525
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Toronto'}]}) RETURN x $$) as (a agtype);
2526
+
count
2527
+
-------
2528
+
1
2529
+
(1 row)
2530
+
2531
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Toronto'}, {city: 'Vancouver'}]}) RETURN x $$) as (a agtype);
2532
+
count
2533
+
-------
2534
+
1
2535
+
(1 row)
2536
+
2537
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Alberta'}]}) RETURN x $$) as (a agtype);
2538
+
count
2539
+
-------
2540
+
0
2541
+
(1 row)
2542
+
2543
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {school:{program:{major:'Psyc'}}}) RETURN x $$) as (a agtype);
2544
+
count
2545
+
-------
2546
+
1
2547
+
(1 row)
2548
+
2549
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {name:'Bob',school:{program:{degree:'BSc'}}}) RETURN x $$) as (a agtype);
2550
+
count
2551
+
-------
2552
+
1
2553
+
(1 row)
2554
+
2555
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {school:{program:{major:'Cs'}}}) RETURN x $$) as (a agtype);
2556
+
count
2557
+
-------
2558
+
0
2559
+
(1 row)
2560
+
2561
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {name:'Bob',school:{program:{degree:'PHd'}}}) RETURN x $$) as (a agtype);
2562
+
count
2563
+
-------
2564
+
0
2565
+
(1 row)
2566
+
2567
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {phone:[987654321]}) RETURN x $$) as (a agtype);
2568
+
count
2569
+
-------
2570
+
1
2571
+
(1 row)
2572
+
2573
+
SELECT count(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {phone:[654765876]}) RETURN x $$) as (a agtype);
2574
+
count
2575
+
-------
2576
+
0
2577
+
(1 row)
2578
+
2579
+
SELECT * FROM cypher('test_enable_containment', $$ EXPLAIN (COSTS OFF) MATCH (x:Customer {school:{name:'XYZ',program:{degree:'BSc'}},phone:[987654321],parents:{}}) RETURN x $$) as (a agtype);
Copy file name to clipboardExpand all lines: regress/sql/cypher_match.sql
+56
Original file line number
Diff line number
Diff line change
@@ -1077,11 +1077,67 @@ SELECT * FROM cypher('cypher_match', $$ CREATE () WITH * MATCH (x{n0:x.n1}) RETU
1077
1077
SELECT*FROM cypher('cypher_match', $$ MATCH p=(x)-[]->(x:R) RETURN p, x $$) AS (p agtype, x agtype);
1078
1078
SELECT*FROM cypher('cypher_match', $$ MATCH p=(x:r)-[]->(x:R) RETURN p, x $$) AS (p agtype, x agtype);
1079
1079
1080
+
--
1081
+
-- Test age.enable_containment configuration parameter
1082
+
--
1083
+
-- Test queries are run before and after switching off this parameter.
1084
+
-- When on, the containment operator should be used to filter properties.
1085
+
-- When off, the access operator should be used.
1086
+
--
1087
+
1088
+
SELECT create_graph('test_enable_containment');
1089
+
SELECT*FROM cypher('test_enable_containment',
1090
+
$$
1091
+
CREATE (x:Customer {
1092
+
name: 'Bob',
1093
+
school: {
1094
+
name: 'XYZ College',
1095
+
program: {
1096
+
major: 'Psyc',
1097
+
degree: 'BSc'
1098
+
}
1099
+
},
1100
+
phone: [ 123456789, 987654321, 456987123 ],
1101
+
addr: [
1102
+
{city: 'Vancouver', street: 30},
1103
+
{city: 'Toronto', street: 40}
1104
+
]
1105
+
})
1106
+
RETURN x
1107
+
$$) as (a agtype);
1108
+
1109
+
-- With enable_containment on
1110
+
SETage.enable_containment=on;
1111
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Toronto'}]}) RETURN x $$) as (a agtype);
1112
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Toronto'}, {city: 'Vancouver'}]}) RETURN x $$) as (a agtype);
1113
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Alberta'}]}) RETURN x $$) as (a agtype);
1114
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {school:{program:{major:'Psyc'}}}) RETURN x $$) as (a agtype);
1115
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {name:'Bob',school:{program:{degree:'BSc'}}}) RETURN x $$) as (a agtype);
1116
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {school:{program:{major:'Cs'}}}) RETURN x $$) as (a agtype);
1117
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {name:'Bob',school:{program:{degree:'PHd'}}}) RETURN x $$) as (a agtype);
1118
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {phone:[987654321]}) RETURN x $$) as (a agtype);
1119
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {phone:[654765876]}) RETURN x $$) as (a agtype);
1120
+
SELECT*FROM cypher('test_enable_containment', $$ EXPLAIN (COSTS OFF) MATCH (x:Customer {school:{name:'XYZ',program:{degree:'BSc'}},phone:[987654321],parents:{}}) RETURN x $$) as (a agtype);
1121
+
1122
+
-- Previous set of queries, with enable_containment off
1123
+
SETage.enable_containment= off;
1124
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Toronto'}]}) RETURN x $$) as (a agtype);
1125
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Toronto'}, {city: 'Vancouver'}]}) RETURN x $$) as (a agtype);
1126
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {addr:[{city:'Alberta'}]}) RETURN x $$) as (a agtype);
1127
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {school:{program:{major:'Psyc'}}}) RETURN x $$) as (a agtype);
1128
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {name:'Bob',school:{program:{degree:'BSc'}}}) RETURN x $$) as (a agtype);
1129
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {school:{program:{major:'Cs'}}}) RETURN x $$) as (a agtype);
1130
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {name:'Bob',school:{program:{degree:'PHd'}}}) RETURN x $$) as (a agtype);
1131
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {phone:[987654321]}) RETURN x $$) as (a agtype);
1132
+
SELECTcount(*) FROM cypher('test_enable_containment', $$ MATCH (x:Customer {phone:[654765876]}) RETURN x $$) as (a agtype);
1133
+
SELECT*FROM cypher('test_enable_containment', $$ EXPLAIN (COSTS OFF) MATCH (x:Customer {school:{name:'XYZ',program:{degree:'BSc'}},phone:[987654321],parents:{}}) RETURN x $$) as (a agtype);
0 commit comments