Giter VIP home page Giter VIP logo

Comments (3)

LinneaAndersson avatar LinneaAndersson commented on May 25, 2024

@salted-yu Thanks for reporting this, we will look into it and get back to you when we have more information.

from neo4j.

arnefischereit avatar arnefischereit commented on May 25, 2024

Hi @salted-yu,

This is very similar to the problem in #13438:

Skewed data

Core of the problem is that we underestimate how often the pattern ()<-[:POSTS]-(u:User)-[:POSTS]->() occurs: Query 1 expands this later in the plan, which is cheaper, while query 2 expands it early on.

We again underestimate the pattern because of the skewed nature of the dataset: For :User we are far off:

PROFILE
MATCH ()<-[:POSTS]-(u:User)-[:POSTS]->()
RETURN count(*)
==================================================
+-------------------+----+------------------------------+----------------+---------+  
| Operator          | Id | Details                      | Estimated Rows | Rows    |  
+-------------------+----+------------------------------+----------------+---------+  
| +ProduceResults   |  0 | `count(*)`                   |              1 |       1 |  
| |                 +----+------------------------------+----------------+---------+  
| +EagerAggregation |  1 | count(*) AS `count(*)`       |              1 |       1 |  
| |                 +----+------------------------------+----------------+---------+  
| +Filter           |  2 | NOT anon_2 = anon_1          |            117 | 1442388 |  
| |                 +----+------------------------------+----------------+---------+  
| +Expand(All)      |  3 | (u)-[anon_1:POSTS]->(anon_0) |            118 | 1444534 |  
| |                 +----+------------------------------+----------------+---------+  
| +Expand(All)      |  4 | (u)-[anon_2:POSTS]->(anon_3) |           2146 |    2146 |  
| |                 +----+------------------------------+----------------+---------+  
| +NodeByLabelScan  |  5 | u:User                       |          38986 |   38986 |  
+-------------------+----+------------------------------+----------------+---------+

While when restricting to the dominating :Me node, we are closer to the true result:

PROFILE
MATCH ()<-[:POSTS]-(u:Me)-[:POSTS]->()
RETURN count(*)
==================================================
+-------------------+----+------------------------------+----------------+---------+  
| Operator          | Id | Details                      | Estimated Rows | Rows    |  
+-------------------+----+------------------------------+----------------+---------+  
| +ProduceResults   |  0 | `count(*)`                   |              1 |       1 |  
| |                 +----+------------------------------+----------------+---------+  
| +EagerAggregation |  1 | count(*) AS `count(*)`       |              1 |       1 |  
| |                 +----+------------------------------+----------------+---------+  
| +Filter           |  2 | NOT anon_2 = anon_1          |         142322 | 1436402 |  
| |                 +----+------------------------------+----------------+---------+  
| +Expand(All)      |  3 | (u)-[anon_1:POSTS]->(anon_0) |         143760 | 1437601 |  
| |                 +----+------------------------------+----------------+---------+  
| +Expand(All)      |  4 | (u)-[anon_2:POSTS]->(anon_3) |           1199 |    1199 |  
| |                 +----+------------------------------+----------------+---------+  
| +NodeByLabelScan  |  5 | u:Me                         |             10 |       1 |  
+-------------------+----+------------------------------+----------------+---------+

Tweets make the difference

Why doe the plan change by adding the label? Because now we have the option of using a label scan on :Tweet as a starting point, which seems attractive with the bad cardinality estimation.

I hope this clarified the situation again.

Have a nice weekend!

Regards,

Arne

from neo4j.

salted-yu avatar salted-yu commented on May 25, 2024

Thank you!
Have a nice weekend!

from neo4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.