SET or STRICT modifiers on function affect planner row estimates - Mailing list pgsql-hackers

From Michał Kłeczek
Subject SET or STRICT modifiers on function affect planner row estimates
Date
Msg-id 5E915F62-D257-4823-896F-0E4C18D68FBA@kleczek.org
Whole thread Raw
Responses Re: SET or STRICT modifiers on function affect planner row estimates
List pgsql-hackers
Hi Hackers,

I am not sure if this is a bug or I am missing something:

There is a partitioned table with partitions being a mix of foreign and regular tables.
I have a function:

report(param text) RETURNS TABLE(…) STABLE LANGUAGE sql AS
$$
SELECT col1, expr1(col2), expr2(col2), sum(col3) FROM tbl GROUP BY col1, expr1(col2), expr2(col2)
$$

EXPLAIN SELECT * FROM report(‘xyz’);

returns expected plan pushing down aggregate expression to remote server.

When I add STRICT or SET search_path to the function definition, the  plan is (as expected) a simple function scan.
But - to my surprise - auto explain in the logs shows unexpected plan with all nodes scanning partitions having row
estimates= 1 

Is it expected behavior?

—
Michal


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_verifybackup: TAR format backup verification
Next
From: Alexander Lakhin
Date:
Subject: Re: msys inet_pton strangeness