row estimation off the mark when generate_series calls are involved

From: Nikhil Sontakke <nikhil(dot)sontakke(at)enterprisedb(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: row estimation off the mark when generate_series calls are involved
Date: 2010-04-19 06:34:13
Message-ID: x2ta301bfd91004182334r2bb2d0eer61866f04a1d1fef8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Another email which went into the wilderness when I sent it to pgsql-patches.

Regards,
Nikhils

---------- Forwarded message ----------
From: Nikhil Sontakke <nikhil(dot)sontakke(at)enterprisedb(dot)com>
Date: Fri, Apr 16, 2010 at 6:50 PM
Subject: row estimation off the mark when generate_series calls are involved
To: pgsql-patches(at)postgresql(dot)org

Hi,

I observed the following behavior on PG head:

postgres=# create table x(x int);
CREATE TABLE
postgres=# explain verbose insert into public.x values (generate_series(1,10));
------------------------------------------------
 Insert  (cost=0.00..0.01 rows=1 width=0)

postgres=# explain verbose insert into public.x values
(generate_series(1,1000));
------------------------------------------------
 Insert  (cost=0.00..0.01 rows=1 width=0)

So even though generate_series has a prorows value of 1000 (why did we
pick this value, just a guesstimate I guess?), its effects are not
shown in the plan at all. I think the place where we set the
targetlist of the result_plan to sub_tlist, immediately after that we
should update the plan_rows estimate by walking this latest
targetlist. I did that and now we seem to get proper row estimates.

Comments?

Regards,
Nikhils
--
http://www.enterprisedb.com

--
http://www.enterprisedb.com

Attachment Content-Type Size
pghead_estimate.patch text/x-patch 787 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2010-04-19 07:36:17 Re: pgsql: Tune GetSnapshotData() during Hot Standby by avoiding loop
Previous Message Nikhil Sontakke 2010-04-19 06:32:57 CTAS not honoring NOT NULL, DEFAULT modifiers