Thread: Oversight in CREATE FUNCTION + EXPLAIN?

Oversight in CREATE FUNCTION + EXPLAIN?

From
"Joshua D. Drake"
Date:
Hey,

So I ran across this today:

CREATE OR REPLACE FUNCTION RETURN_LOTS(INT) RETURNS SETOF INT AS
   $$
      SELECT generate_series(1,$1);
   $$
COST 0.5 ROWS 50 SET work_mem TO '5MB' LANGUAGE 'SQL';

postgres=# explain analyze select return_lots(10000000);
QUERY PLAN
-----------------------------------------------------------------------------------------------
 Result  (cost=0.00..0.26 rows=1 width=0) (actual time=0.059..21411.187
rows=10000000 loops=1)
 Total runtime: 25951.904 ms

Shouldn't the estimated rows be 50?

Joshua D. Drake


--
PostgreSQL.org Major Contributor
Command Prompt, Inc: http://www.commandprompt.com/ - 503.667.4564
Consulting, Training, Support, Custom Development, Engineering
If the world pushes look it in the eye and GRR. Then push back harder. - Salamander

Re: Oversight in CREATE FUNCTION + EXPLAIN?

From
Tom Lane
Date:
"Joshua D. Drake" <jd@commandprompt.com> writes:
> Shouldn't the estimated rows be 50?

It is if you do "select * from return_lots(10000000)".
        regards, tom lane