@@ -626,6 +626,19 @@ $$) as (name agtype);
626626 "Tijuana"
627627(6 rows)
628628
629+ -- EXPLAIN for pattern with WHERE clause
630+ SELECT * FROM cypher('cypher_index', $$
631+ EXPLAIN (costs off) MATCH (a:City)
632+ WHERE a.country_code = 'US' AND a.west_coast = true
633+ RETURN a
634+ $$) as (plan agtype);
635+ QUERY PLAN
636+ -------------------------------------------------------------------------------------------------------------
637+ Index Scan using city_west_coast_idx on "City" a
638+ Index Cond: (agtype_access_operator(VARIADIC ARRAY[properties, '"west_coast"'::agtype]) = 'true'::agtype)
639+ Filter: (agtype_access_operator(VARIADIC ARRAY[properties, '"country_code"'::agtype]) = '"US"'::agtype)
640+ (3 rows)
641+
629642-- Test WHERE with multiple conditions (AND)
630643SELECT * FROM cypher('cypher_index', $$
631644 MATCH (a:City)
@@ -700,6 +713,27 @@ $$) as (name agtype);
700713 "Mexico"
701714(1 row)
702715
716+ -- EXPLAIN for pattern with filters on both country and city
717+ SELECT * FROM cypher('cypher_index', $$
718+ EXPLAIN (costs off) MATCH (country:Country)<-[:has_city]-(city:City)
719+ WHERE country.country_code = 'CA' AND city.west_coast = true
720+ RETURN city.name
721+ $$) as (plan agtype);
722+ QUERY PLAN
723+ -------------------------------------------------------------------------------------------------------------------------
724+ Nested Loop
725+ -> Nested Loop
726+ -> Index Scan using city_west_coast_idx on "City" city
727+ Index Cond: (agtype_access_operator(VARIADIC ARRAY[properties, '"west_coast"'::agtype]) = 'true'::agtype)
728+ -> Bitmap Heap Scan on has_city _age_default_alias_0
729+ Recheck Cond: (start_id = city.id)
730+ -> Bitmap Index Scan on has_city_start_id_idx
731+ Index Cond: (start_id = city.id)
732+ -> Index Scan using "Country_pkey" on "Country" country
733+ Index Cond: (id = _age_default_alias_0.end_id)
734+ Filter: (agtype_access_operator(VARIADIC ARRAY[properties, '"country_code"'::agtype]) = '"CA"'::agtype)
735+ (11 rows)
736+
703737-- Test WHERE in combination with pattern matching
704738SELECT * FROM cypher('cypher_index', $$
705739 MATCH (country:Country)<-[:has_city]-(city:City)
0 commit comments