Re: Row estimates for empty tables

2020-08-24 Thread Justin Pryzby
On Fri, Jul 24, 2020 at 09:14:04PM +0200, Pavel Stehule wrote: > pá 24. 7. 2020 v 16:38 odesílatel Christophe Pettus > napsal: > > Since we already special-case parent tables for partition sets, would a > > storage parameter that lets you either tell the planner "no, really, zero > > is reasonabl

Re: Row estimates for empty tables

2020-07-24 Thread Christophe Pettus
> On Jul 24, 2020, at 14:09, Tom Lane wrote: > Rather than adding another pg_class column, I'm tempted to say that > vacuum/analyze should set relpages to a minimum of 1, even if the > relation has zero pages. If there's not an issue about relpages != actual pages on disk, that certain seems

Re: Row estimates for empty tables

2020-07-24 Thread Tom Lane
Pavel Stehule writes: > pá 24. 7. 2020 v 16:38 odesílatel Christophe Pettus > napsal: >> Since we already special-case parent tables for partition sets, would a >> storage parameter that lets you either tell the planner "no, really, zero >> is reasonable here" or sets a minimum number of rows to

Re: Row estimates for empty tables

2020-07-24 Thread Christophe Pettus
> On Jul 24, 2020, at 12:14, Pavel Stehule wrote: > > this application stores some results in tables (as guard against repeated > calculations). Lot of these tables have zero or one row. Yes, that's the situation we encountered, too. It's not very common (and even less common, I would assu

Re: Row estimates for empty tables

2020-07-24 Thread Pavel Stehule
pá 24. 7. 2020 v 16:38 odesílatel Christophe Pettus napsal: > > > > On Jul 24, 2020, at 06:48, Tom Lane wrote: > > > > There's certainly not a lot besides tradition to justify the exact > > numbers used in this case. > > Since we already special-case parent tables for partition sets, would a > s

Re: Row estimates for empty tables

2020-07-24 Thread Christophe Pettus
> On Jul 24, 2020, at 06:48, Tom Lane wrote: > > There's certainly not a lot besides tradition to justify the exact > numbers used in this case. Since we already special-case parent tables for partition sets, would a storage parameter that lets you either tell the planner "no, really, zero

Re: Row estimates for empty tables

2020-07-24 Thread Tom Lane
David Rowley writes: > On Fri, 24 Jul 2020 at 16:01, Christophe Pettus wrote: >> I realize I've never quite known this; where does the planner get the row >> estimates for an empty table? Example: > We just assume there are 10 pages if the relation has not yet been > vacuumed or analyzed. The

Re: Row estimates for empty tables

2020-07-23 Thread David Rowley
On Fri, 24 Jul 2020 at 16:01, Christophe Pettus wrote: > I realize I've never quite known this; where does the planner get the row > estimates for an empty table? Example: We just assume there are 10 pages if the relation has not yet been vacuumed or analyzed. The row estimates you see are the

Row estimates for empty tables

2020-07-23 Thread Christophe Pettus
I realize I've never quite known this; where does the planner get the row estimates for an empty table? Example: psql (11.8) Type "help" for help. xof=# CREATE TABLE t (i integer, t text, j integer); CREATE TABLE xof=# VACUUM ANALYZE t; VACUUM xof=# EXPLAIN ANALYZE SELECT * FROM t;