Re: Extremely slow HashAggregate in simple UNION query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On 21. Aug 2019, at 20:26, Jeff Janes <jeff.janes@xxxxxxxxx> wrote:
> 
> As noted elsewhere, v12 thwarts your attempts to deliberately design the bad estimates.  You can still get them, you just have to work a bit harder at it:
> 
> CREATE FUNCTION j (bigint, bigint) returns setof bigint as $$ select generate_series($1,$2) $$ rows 1000 language sql;

Yeah, that's awesome! I didn't know about this until I ran into this issue, I'll definitely be using it for future estimation problems that are difficult to fix otherwise!

> I've made an extension which has a function which always returns true, but lies about how often it is expected to return true. See the attachment.  With that, you can fine-tune the planner.
> 
> CREATE EXTENSION pg_selectivities ;

Very cool and useful : )!

I think in most cases I'll be okay with declaring a function with a static ROWS estimate, but I'll consider your extension if I need more flexibility in the future!

Thanks
Felix





[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux