Skip to content

The lsqb four-cycle pays for its relationship inequalities a row at a time #425

Description

@tamnd

lsqb-q7 is the undirected KNOWS four-cycle, and it is the one shape in that family where zu comes in behind ladybug: 53.82s against 13.07s at sf1 on the social-1k graph, both engines in process, p50 against p50.

The cycle is not what costs. The other three cyclic shapes in the family are all ahead, q5 by 10.0x, q6 by 8.7x and q9 by 85.1x, and they close the same way over the same KNOWS graph. What q7 has that they do not is a predicate over bound relationships, six of them:

MATCH (a:Person)-[r1:KNOWS]-(b:Person)-[r2:KNOWS]-(c:Person)-[r3:KNOWS]-(d:Person)-[r4:KNOWS]-(a)
WHERE r1 <> r2 AND r1 <> r3 AND r1 <> r4 AND r2 <> r3 AND r2 <> r4 AND r3 <> r4
RETURN count(*) AS cnt

The four relationships are named and required distinct on purpose, because Cypher specifies relationship isomorphism and Kuzu evaluates the same text as a plain join, so the text has to spell the constraint out to mean one thing on both engines.

The reading to check is that the six inequalities land above the close as a row filter rather than inside it. r1 <> r2 is a statement about two legs that share node b, and it can be settled while b is being expanded, before c and d exist at all. Settled where it is, it is settled once per closed four-walk, and the count on this graph is 123187824 of them.

What to look at is whether an inequality between two bound relationships can be pushed to the point where its second side is bound, the way a property predicate already is, and whether the close can take the ones that constrain its own two legs. The measurement to repeat afterwards is gb run --workload lsqb --engines zu,ladybug --scale sf1.

Found while closing #304, which is what let this query run against zu at all.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    benchBenchmarks and CI gatesperfPerformance and resource budgetsqueryParser, planner, executor

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions