Skip to content

Match queries with integer properties constraints return 0 results after adding gin index #228

Closed

Description

@pdpotter

Describe the bug
When a GIN index is added to the properties of a vertex, MATCH queries with a constraint on an integer property return 0 results.

How are you accessing AGE (Command line, driver, etc.)?

  • psql

What data setup do we need to do?

SELECT * FROM cypher('cypher_index', $$CREATE (p:Person {id: 1, name: 'John'}) return p$$) as (p agtype);
CREATE INDEX props on cypher_index."Person" USING GIN (properties);
SET enable_seqscan=false;

What is the necessary configuration info needed?

  • /

What is the command that caused the error?

SELECT * FROM cypher('cypher_index', $$MATCH (p:Person {id: 1}) return p$$) as (p agtype);
 p 
---
(0 rows)

Expected behavior
One row should be returned

Environment (please complete the following information):

Additional context
This bug is a minimal reproduction of the issue described in #45 (comment)

The same query wih a constraint on a string property gives correct results:

SELECT * FROM cypher('cypher_index', $$MATCH (p:Person {name: 'John'}) return p$$) as (p agtype);
                                              p                                              
---------------------------------------------------------------------------------------------
 {"id": 844424930131969, "label": "Person", "properties": {"id": 1, "name": "John"}}::vertex
(1 row)

Explain for the integer property constraint:

SELECT * FROM cypher('cypher_index', $$EXPLAIN MATCH (p:Person {id: 1}) return p$$) as (p agtype);
                                  QUERY PLAN                                   
-------------------------------------------------------------------------------
 Bitmap Heap Scan on "Person" p  (cost=12.00..16.02 rows=1 width=32)
   Recheck Cond: (properties @> agtype_build_map('id'::text, '1'::agtype))
   ->  Bitmap Index Scan on props  (cost=0.00..12.00 rows=1 width=0)
         Index Cond: (properties @> agtype_build_map('id'::text, '1'::agtype))
(4 rows)

Explain for the string property constraint:

SELECT * FROM cypher('cypher_index', $$EXPLAIN MATCH (p:Person {name: 'John'}) return p$$) as (p agtype);
                                      QUERY PLAN                                      
--------------------------------------------------------------------------------------
 Bitmap Heap Scan on "Person" p  (cost=12.00..16.02 rows=1 width=32)
   Recheck Cond: (properties @> agtype_build_map('name'::text, '"John"'::agtype))
   ->  Bitmap Index Scan on props  (cost=0.00..12.00 rows=1 width=0)
         Index Cond: (properties @> agtype_build_map('name'::text, '"John"'::agtype))
(4 rows)

Activity

  1. added
    bug
    on Jun 7, 2022
  2. pdpotter commented on Aug 10, 2022

    @pdpotter
    Author

    This issue has been fixed in 392a937.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions