Re: Want function to be called only once in query

2021-09-16 Thread Steve Pritchard
16, 2021 at 4:51 AM Steve Pritchard > wrote: > > > > I have a PL/pgSQL function that I want to call within a query, but the > function is fairly expensive to execute so I only want it executed once > within the query. However the planner seems to reorganize my query so that

Want function to be called only once in query

2021-09-16 Thread Steve Pritchard
- (in Pg 9.6, test_caching(...) is only called once) with tc as ( select test_caching(7) offset 0 ) select n, tc.test_caching from tc cross join generate_series(1, 10) n; -- test_caching(...) is called once -- works, but a kludge Steve -- Steve Pritchard Database Developer British Trust for Or

Re: Inaccurate Rows estimate for "Bitmap And" causes Planner to choose wrong join

2020-05-13 Thread Steve Pritchard
ects don't seem to be able to handle the combination of dependencies and arrays (at least in 12.2). Steve On Wed, 6 May 2020 at 19:25, Jeff Janes wrote: > On Wed, May 6, 2020 at 12:20 PM Steve Pritchard > wrote: > >> Version: Postgres 9.6.3 production system (but also tested

Inaccurate Rows estimate for "Bitmap And" causes Planner to choose wrong join

2020-05-06 Thread Steve Pritchard
l different combinations that can arise (it would require quite a few indexes to cover all the possible combinations). However if I did have such an index, the planner would presumably be able to use the statistics for user_id and loc_id to estimate the number of rows. So why can't it make an