Repository navigation
Description
Describe the bug
GIN indexes on Specific properties does not seem to work. This is basing off of the issue #954
How are you accessing AGE (Command line, driver, etc.)?
- [e.g. JDBC]
What data setup do we need to do?
...
SELECT create_graph('cypher_index');
SELECT create_vlabel('cypher_index', 'Movie');
CREATE INDEX imdb ON cypher_index."Movie" USING gin ((properties->'imdbRank'));
SELECT * from cypher('cypher_index', $$
CREATE
(:Movie {id: 'movie1', name: 'The Shawshank Redemption', imdbRank : 25}),
(:Movie {id: 'movie2', name: 'The Godfather', imdbRank : 60}),
(:Movie {id: 'movie3', name: 'The Dark Knight', imdbRank : 100})
$$) as (V agtype);
...
-- Explain plans are not using the index
SELECT * FROM cypher('cypher_index', $$ EXPLAIN ANALYZE MATCH(n:Movie) where n.imdbRank = 25 return n $$) AS (a agtype);Result of the above EXPLAIN query
"Seq Scan on ""Movie"" n (cost=0.00..34.03 rows=6 width=32) (actual time=0.019..0.025 rows=1 loops=1)"
" Filter: (agtype_access_operator(VARIADIC ARRAY[_agtype_build_vertex(id, _label_name('91013'::oid, id), properties), '""imdbRank""'::agtype]) = '25'::agtype)"
Rows Removed by Filter: 2
Planning Time: 0.058 ms
Execution Time: 0.037 ms
Another EXPLAIN query using the MATCH by property
SELECT * FROM cypher('cypher_index', $$ EXPLAIN ANALYZE MATCH(n:Movie {imdbRank: 25}) return n $$) AS (a agtype);
Result from the above plan
"Seq Scan on ""Movie"" n (cost=0.00..28.00 rows=1 width=32) (actual time=0.016..0.018 rows=1 loops=1)"
" Filter: (properties @> agtype_build_map('imdbRank'::text, '25'::agtype))"
Rows Removed by Filter: 2
Planning Time: 0.051 ms
Execution Time: 0.031 ms
What is the necessary configuration info needed?
Just pg13 with the latest release of apache age
What is the command that caused the error?
SELECT * from cypher('my_graph_name', $$
MATCH (a:Part {part_num: '123'}), (b:Part {part_num: '345'})
CREATE (a)-[u:used_by { quantity: 1 }]->(b)
$$) as (a agtype);ERROR: something failed to execute
Expected behavior
The query should be hitting the GIN index
Environment (please complete the following information):
- Version: Postgres13 with the latest tag of Apache AGE compiled and added.
Additional context
Based on the discussions reported in other issues posted earlier indexing seems to be a bit of a riddle. I have been able to add uniqueness based on a unique index on a property in the json be example, but that index doesn't get used when running match queries.
Activity
ddrao commentedon Jun 26, 2023
This might be a duplicate of #1000
jrgemignani commentedon Jun 27, 2023
@MuhammadTahaNaveed @Zainab-Saad as they might be working on a related patch mentioned in #1000
pdpotter commentedon Jun 29, 2023
There are indeed multiple issues with indexing that you might be experiencing:
->,->>) to Agtype #212 (comment)?[edit] I just realized there is another indexing issue that maybe should be added here (but which I haven't encountered myself):
jrgemignani commentedon Jun 29, 2023
@pdpotter Thank you for pulling these altogether in a nice concise list. I will have our team look at working on each of these items.
@MuhammadTahaNaveed @Zainab-Saad @CapnSpek @dehowef Let us know if you might be interested in any of these :)
jrgemignani commentedon Oct 21, 2023
@arca1n I believe this issue has been resolved in the master branch. Would you be able to verify it on your end?
pdpotter commentedon Dec 11, 2023
I tried the latest code in the master branch. Unfortunately, indexes on specific property indexes still aren't used in my reproduction (both on a numeric property as on a textual property).
Reproduction:
Do the specific property indexes need to be constructed differently?
rafsun42 commentedon Dec 11, 2023
@pdpotter
GIN indexes are usually created on the entire column rather than an expression-
jrgemignani commentedon Dec 11, 2023
@pdpotter I just want to point out that once an index is created, it is up to PostgreSQL to use it or not. It is entirely possible that the PostgreSQL planner/optimizer may decide the index would not improve the query and just ignore it.
github-actions commentedon May 11, 2024
This issue is stale because it has been open 45 days with no activity. Remove "Abondoned" label or comment or this will be closed in 7 days.
github-actions commentedon May 19, 2024
This issue was closed because it has been stalled for further 7 days with no activity.
Fix MERGE to use indexes by removing volatile wrapper hack
Fix MERGE to use indexes by removing volatile wrapper hack