pdpotter commented on issue #45: URL: https://github.com/apache/incubator-age/issues/45#issuecomment-982438807
This is great, thank you! Since indices require an immutable function, an additional function will still need to be created for them. When I create a `get_id` function with ``` CREATE OR REPLACE FUNCTION get_id(properties agtype) RETURNS agtype AS $BODY$ select agtype_access_operator($1, '"id"'); $BODY$ LANGUAGE sql IMMUTABLE; ``` and use it in an index with ``` CREATE UNIQUE INDEX person_id_idx ON mygraph.person(get_id(properties)) ; ``` the creation of vertices with the same id will be prevented ``` ERROR: duplicate key value violates unique constraint "person_id_idx" DETAIL: Key (get_id(properties))=(2250) already exists. ``` but the index will still not be used when trying to match vertices with a specific id: ``` SELECT * FROM ag_catalog.cypher('mygraph', $$EXPLAIN ANALYZE MATCH (a:person {id:2250}) return a$$) as (a agtype); ``` ``` QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------- Seq Scan on person a (cost=0.00..2775.32 rows=16906 width=32) (actual time=12.688..85.521 rows=1 loops=1) Filter: _property_constraint_check(properties, agtype_build_map('id'::text, '2250'::agtype)) Rows Removed by Filter: 50718 Planning Time: 0.122 ms Execution Time: 85.550 ms (5 rows) ``` Is there a way to use indices when matching? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@age.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org