Skip to content

Conversation

@andr-sokolov
Copy link

The default value of join_collapse_limit was 20. When this value is set and
the query contains about 20 joins (see added test), Postgres query optimizer
cannot build a plan during hours and consumes a lot of memory, because the
planner checks a lot of possible ways to join the tables.
When join_collapse_limit is 8, the query plan is built in reasonable time.

…QL 14

The default value of join_collapse_limit was 20. When this value is set and
the query contains about 20 joins (see added test), Postgres query optimizer
cannot build a plan during hours and consumes a lot of memory, because the
planner checks a lot of possible ways to join the tables.
When join_collapse_limit is 8, the query plan is built in reasonable time.
@andr-sokolov
Copy link
Author

I suggest join_collapse_limit=8 to reduce the difference from PostgreSQL 14, but you can consider slightly larger values. In the table below there are time and memory consumption to process the query from the test.

join_collapse_limit Query processing time, ms Backend memory usage
8 96 52 MB
9 230 88 MB
10 653 210 MB
11 1269 394 MB
12 2994 889 MB
13 9003 2.4 GB
14 27245 7.3 GB
15 80904 22 GB
16 670578 66 GB
17 4158314 200 GB

Query processing time was got using \timing on in psql. Backend memory usage was measured at the end of the planner function

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant