or() operator in a graph query will scan the full vertex table, ignoring any index on the vertex properties.
A typical single-level
or() scenario occurs when querying one vertex for two different values of the same vertex property:
profile() of this query will show that even if a materialized view (MV) index was created for the property firstName, the index will not be used. This will obviously increase the query execution time.
or() operator was designed to work with vertexes of different types and different properties. Because of this feature, it will ignore any index because no logic exists to decide which index to use. An internal jira (DSP-11534 “Fix folding of OR and AND conditions.”) is aiming at resolving this issue and avoiding the table scan when using
Other ways to achieve the same results of a single-level (non nested)
or(), may include a
search()index or the use of
within() will use the MV indexes when they are available.
An example of
within() operator is:
g.V().has('person', 'firstName', within('Tissa', 'Lotfi'))
A complete solution will be released with DSP-11534.