Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push Filter Down BiInnerJoin and Traverse PlanNode #4937

Closed
yixinglu opened this issue Nov 25, 2022 · 1 comment
Closed

Push Filter Down BiInnerJoin and Traverse PlanNode #4937

yixinglu opened this issue Nov 25, 2022 · 1 comment
Assignees
Labels
type/enhancement Type: make the code neat or more efficient

Comments

@yixinglu
Copy link
Contributor

yixinglu commented Nov 25, 2022

query in sf100 dataset:

MATCH (person)-[:KNOWS*1..2]-(friend)-[:IS_LOCATED_IN]->(city:Place)-[:IS_PART_OF]->(country:Place)
WHERE id(person) == "p-8796093163356" AND id(friend) != "p-8796093163356" AND country.Place.name != "Papua_New_Guinea" AND country.Place.name != "Namibia"
WITH DISTINCT friend
MATCH (friend)<-[:POST_HAS_CREATOR|COMMENT_HAS_CREATOR]-(message)-[:IS_LOCATED_IN]->(country)
WHERE country.Place.name IN ["Papua_New_Guinea", "Namibia"] AND
    CASE
    WHEN message.`Comment`.creationDate < datetime(1306886400)+Duration({days:52}) AND message.`Comment`.creationDate >= datetime(1306886400) THEN true
    WHEN message.Post.creationDate < datetime(1306886400)+Duration({days:52}) AND message.Post.creationDate >= datetime(1306886400) THEN true
    ELSE false
    END
WITH friend,
     CASE WHEN country.Place.name == "Papua_New_Guinea" THEN 1 ELSE 0 END AS messageX,
     CASE WHEN country.Place.name == "Namibia" THEN 1 ELSE 0 END AS messageY
WITH friend, sum(messageX) AS xCount, sum(messageY) AS yCount
WHERE xCount>0 AND yCount>0
RETURN tointeger(substr(id(friend), 2)) AS friendId,
  friend.Person.firstName AS friendFirstName,
  friend.Person.lastName AS friendLastName,
  xCount,
  yCount,
  xCount + yCount AS xyCount
ORDER BY xyCount DESC, friendId ASC
LIMIT 20

execution plan:

image

The following Filter Conditions should be pushed below the above plan nodes:

WHERE country.Place.name IN ["Papua_New_Guinea", "Namibia"] AND
    CASE
    WHEN message.`Comment`.creationDate < datetime(1306886400)+Duration({days:52}) AND message.`Comment`.creationDate >= datetime(1306886400) THEN true
    WHEN message.Post.creationDate < datetime(1306886400)+Duration({days:52}) AND message.Post.creationDate >= datetime(1306886400) THEN true
    ELSE false
    END
@yixinglu yixinglu added the type/enhancement Type: make the code neat or more efficient label Nov 25, 2022
@jievince
Copy link
Contributor

#4987 and #4956 have done it. So close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Type: make the code neat or more efficient
Projects
None yet
Development

No branches or pull requests

3 participants