Skip to main content
added 498 characters in body
Source Link
Laurenz Albe
  • 56.4k
  • 4
  • 50
  • 82

The secret is in the Rows Removed by Filter: 10115028:

It takes the sequential scan 17 seconds to find and return the first result row.

  1. The secret is in the Rows Removed by Filter: 10115028:

    It takes the sequential scan 17 seconds to find and return the first result row.

  2. The optimizer has no idea how long it takes until the first row passes the filter. Since it doesn't make any difference for the quality of the plan, it just sets the startup cost to 0.

  3. Both plans work the same: each of the three processes scans a third of the table and counts the rows (the Partial Aggregate that returns 1 row). In the first case, 10 million rows are counted by each worker.

    These three numbers are gathered and summed in the Finalize Aggregate stage.

The secret is in the Rows Removed by Filter: 10115028:

It takes the sequential scan 17 seconds to find and return the first result row.

  1. The secret is in the Rows Removed by Filter: 10115028:

    It takes the sequential scan 17 seconds to find and return the first result row.

  2. The optimizer has no idea how long it takes until the first row passes the filter. Since it doesn't make any difference for the quality of the plan, it just sets the startup cost to 0.

  3. Both plans work the same: each of the three processes scans a third of the table and counts the rows (the Partial Aggregate that returns 1 row). In the first case, 10 million rows are counted by each worker.

    These three numbers are gathered and summed in the Finalize Aggregate stage.

Source Link
Laurenz Albe
  • 56.4k
  • 4
  • 50
  • 82

The secret is in the Rows Removed by Filter: 10115028:

It takes the sequential scan 17 seconds to find and return the first result row.