Join Passdown
The Simba Neo4j JDBC Driver can pass down join operations to the Neo4j server for execution. This improves the performance of the connector. Queries that are not passed down are executed by the connector.
The connector can pass down queries that involve single columns or literals as the operands.
For example, the following join conditions can be passed down to the server:
- table1.col1 = table2.col1
- table1.col1 > table2.col1 AND table1.col2 LIKE table2.col2
- table1.col1 <> 'value'
The following conditions are not supported for join passdown:
- table1.col1 + table1.col2 < table2.col3
- CONCAT('this', ' value') = table1.col1
Join Operations on Subqueries
The join operation can only be passed down if both operands of the join are individually able to be passed down. If one of the operands contains a clause that is not able to be passed down, then it is not possible to pass down the join operation.
For example, the following query cannot be passed down:
SELECT * FROM (SELECT * FROM table1 WHERE col1 + col2 > 1000) t1 INNER JOIN table2 ON t1.col1=t2.col2
In this example, the "col1 + col2 > 1000" condition cannot be passed down, so the join operation cannot be passed down.
Note:
Subqueries involving TOP, LIMIT, or aggregation operations are also not supported as one of the JOIN operands.
Multiple Joins with AND
When conditions are separated by AND and one condition cannot be passed down, the join operation on remaining conditions are passed down to the Neo4j server while the conditions not passed down are handled by the SQLEngine.
For example, the following query can be fully passed down to the Neo4j server:
SELECT * FROM table1 INNER JOIN table2 ON table1.col1=table2.col1 INNER JOIN table3 ON table2.col1=table2.col1 AND table2.col2 LIKE table3.col2
As another example, the following query, using AND, cannot be fully passed down to the Neo4j server:
SELECT * FROM table1 INNER JOIN table2 ON table1.col1=table2.col1 AND table1.col2+table1.col3 > table2.col2
In this example, the "SELECT * FROM table1 INNER JOIN table2 ON table1.col1=table2.col1" condition is passed down to the Neo4j server, while the "table1.col2+table1.col3 > table2.col2" condition is handled by the SQLEngine.
Important:
When comparing strings with different lengths, the connector handles the "=" condition on strings differently from the Neo4j server. The connector pads the value with whitespaces, while the Neo4j server does not.
For example, when resolving "col1=col2", if the value of col1 is 'ValueTest ' and col2 is 'ValueTest', the connector reports a match, but the Neo4j server does not.