Using index hints
Index hints are used to specify which indexes the planner should try to use. This can change how the query gets executed. There might be a trade-off compared to the default planning when using index hints.
We can provide index hints to the planner with a USING
clause. Let’s take a sample query that uses multiple entities and review a basic query profile and index hint driver query profile:
MATCH path= (p:Patient {id:'7361ce15-cf67-ae76-88e6-bcbdca19ce0b'}) -[:HAS_ENCOUNTER]->() -[:HAS_DRUG]->(d:Drug {code:'1190795'}) RETURN path LIMIT 1
We will take the preceding query and get a basic query profile first:
PROFILE MATCH path= (p:Patient {id:'7361ce15-cf67-ae76-88e6-bcbdca19ce0b'}) -[:HAS_ENCOUNTER]->() -[:HAS_DRUG]->(d:Drug {code:'1190795'}) RETURN path LIMIT 1
The following screenshot represents a basic query profile:
Figure 9.11 – Basic query profile without hints...