On Mon, Nov 25, 2019 at 01:00:34PM +0000, PG Bug reporting form wrote:
>The following bug has been logged on the website:
>
>Bug reference: 16136
>Logged by: Александр Филиппенко
>Email address: alexfilus@gmail.com
>PostgreSQL version: 12.1
>Operating system: Ubuntu 18.04
>Description:
>
>I had very strange behaviour of optimizator.
>https://explain.depesz.com/s/GcHL
>https://explain.depesz.com/s/sTyG
>Both explains are for same query and same data set, but in second case I
>turn off JIT. I guess it's because of wrong cost calculation like this
>Nested Loop (cost=463.86..5575122.76 rows=652 width=74) (actual
>time=9.685..67.713 rows=18 loops=1)
>
Not sure what exactly you mean by "wrong cost calculation"?
The reason for the long duration with JIT seems pretty clear:
Functions: 237
Options: Inlining true, Optimization true, Expressions true, Deforming true
Timing: Generation 45.190 ms, Inlining 37.452 ms, Optimization 1292.680 ms, Emission 1076.752 ms, Total 2452.074 ms
That is, it took about 2.3s to optimize and emit the JIT code, most
likely because due to a fairly high number of functions. I'm not sure
that's something we can really fix, but there were discussions about
being smarter about optimizations etc.
regards
--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services