Re: Access plan selection logic PG9.2 -> PG14

2023-09-15 Thread David Rowley
On Fri, 15 Sept 2023 at 21:13, Ryo Yamaji (Fujitsu) wrote: > The following example shows a table with 1 million tuples: > * The cost of using PK was higher than the cost of using user index. > * It was faster to use PK. > > Index Scan using tbl_ix1 on tbl (cost=0.43..0.67 rows=1 width=61) (actua

RE: Access plan selection logic PG9.2 -> PG14

2023-09-15 Thread Ryo Yamaji (Fujitsu)
on Fri, 15 Sept 2023 at 0:00, Adrian Klaver wrote: > Why not just run ANALYZE on the new 14.7 instance? The statistics were manually updated to fix the access plan. I was trying to see if I could fix the access plan in a similar way in 9.2 -> 14.7. I probably will run ANALYZE soon because I hav

RE: Access plan selection logic PG9.2 -> PG14

2023-09-15 Thread Ryo Yamaji (Fujitsu)
on Thu, 14 Sept 2023 at 23:43, David Rowley wrote: > This likely is due to the query planner not giving any preference to the > index that allows more quals to go into the index condition. Once the > selectivity estimate gets as low as 1 row then the costs between each index > don't vary very

Re: Access plan selection logic PG9.2 -> PG14

2023-09-14 Thread Adrian Klaver
On 9/14/23 00:15, Ryo Yamaji (Fujitsu) wrote: Hi all I am planning to migrate from PostgreSQL9.2 to PostgreSQL14.7. Running the same SQL with the same statistics as previous versions resulted in different access plans. I have no knowledge of the PostgreSQL planner and would like to be informed

Re: Access plan selection logic PG9.2 -> PG14

2023-09-14 Thread David Rowley
On Fri, 15 Sept 2023 at 01:36, Ryo Yamaji (Fujitsu) wrote: > Question: > I am assuming that the version upgrade has changed the behavior of the > planner. Is this correct? It's possible. 9.2 was a long time ago. It would be quite a bit of work to determine if this is the case. You could perhap