BUG #15184: Planner overestimates number of rows in empty table
От | PG Bug reporting form |
---|---|
Тема | BUG #15184: Planner overestimates number of rows in empty table |
Дата | |
Msg-id | 152533737110.23585.5446055718425840639@wrigleys.postgresql.org обсуждение исходный текст |
Ответы |
Re: BUG #15184: Planner overestimates number of rows in empty table
|
Список | pgsql-bugs |
The following bug has been logged on the website: Bug reference: 15184 Logged by: Alexey Ermakov Email address: alexey.ermakov@dataegret.com PostgreSQL version: 10.3 Operating system: Linux Description: Hello, in optimizer/util/plancat.c we have following lines (https://github.com/postgres/postgres/blob/master/src/backend/optimizer/util/plancat.c#L957): if (curpages < 10 && rel->rd_rel->relpages == 0 && !rel->rd_rel->relhassubclass && rel->rd_rel->relkind != RELKIND_INDEX) curpages = 10; /* report estimated # pages */ *pages = curpages; /* quick exit if rel is clearly empty */ if (curpages == 0) { *tuples = 0; *allvisfrac = 0; break; } if table is really empty then in first condition we set curpages = 10 and second condition doesn't apply. so we estimate that empty table has 10 pages and 2550 rows (for table with one int column) which doesn't look good. is it intended behavior? perhaps we should add (curpages > 0) condition ? that overestimate could mess plans for example when we use temporary tables which might be empty. Thanks, Alexey Ermakov
В списке pgsql-bugs по дате отправления: