Re:Re:Re: Different execution plan between PostgreSQL 8.2 and 12.5

2022-08-19 Thread gzh
Dear Adrian, Sorry, there is an error in the email just replied, the version of PostgreSQL is wrong. PostgreSQL 8.4 → PostgreSQL 8.2 At 2022-08-19 12:42:54, "gzh" wrote: Dear Adrian, I appreciate your reply. Your reply gave me a new idea, it should not be the problem that the

Re:Re: Different execution plan between PostgreSQL 8.2 and 12.5

2022-08-18 Thread gzh
Dear Adrian, I appreciate your reply. Your reply gave me a new idea, it should not be the problem that the lower() function causes the unique index to fail. I checked the postgresql.conf file and found that shared_buffers, work_mem and maintenance_work_mem are default value, but in the pos

Re: Different execution plan between PostgreSQL 8.2 and 12.5

2022-08-18 Thread Adrian Klaver
On 8/18/22 02:50, gzh wrote: Dear Tom, Thanks for your reply. Please refer to the information below: I run following sql in PostgreSQL 8.2 and PostgreSQL 12.5, it returns different execution plan. There are ~13 years of improvements to the planner and the database as a whole, I would mo

Re: Re: Different execution plan between PostgreSQL 8.2 and 12.5

2022-08-18 Thread Torsten Krah
But you should do that according to the documentation: ... After restoring a backup, it is wise to run ANALYZE on each database so the query optimizer has useful statistics. ...

Re:Re: Different execution plan between PostgreSQL 8.2 and 12.5

2022-08-18 Thread gzh
Dear Adrian, Thanks for your reply. >Did you run ANALYZE on the 12.5 server after restoring the data to it? No, I did not run ANALYZE on the 12.5 server after restoring the data. When I change the select clause like this ( crew_base.crewid → count(*) ), I can retrieve the number of data r

Re:Re: Different execution plan between PostgreSQL 8.2 and 12.5

2022-08-18 Thread gzh
Dear David, Thanks for your reply. >In addition to that, I couldn't help notice that the quoted SQL does >not seem to belong to the explain. The EXPLAIN has a Limit node, but >the query does not. I'm assuming this isn't due to the relations being >views since we don't pull up subqueries with a L

Re:Re: Different execution plan between PostgreSQL 8.2 and 12.5

2022-08-18 Thread gzh
Dear Tom, Thanks for your reply. Please refer to the information below: PostgreSQL 8.2 [root@PostgreSQL8 ~]# cat /etc/redhat-release CentOS release 6.6 (Final) [root@PostgreSQL8 ~]# locale | grep LANG LANG=ja_JP.UTF-8 PostgreSQL 12.5 [root@Postgr

Re: Different execution plan between PostgreSQL 8.2 and 12.5

2022-08-17 Thread Adrian Klaver
On 8/17/22 20:01, gzh wrote: Hi, I have had a Perl Website working for 7 years and have had no problems until a few weeks ago I replaced my database server with a newer one. Did you run ANALYZE on the 12.5 server after restoring the data to it? gzh -- Adrian Klaver adrian.kla...@akl

Re: Different execution plan between PostgreSQL 8.2 and 12.5

2022-08-17 Thread David Rowley
On Thu, 18 Aug 2022 at 15:32, Tom Lane wrote: > The 12.5 plan looks like it thinks that the join condition is not > hashable --- and probably not mergeable as well, else it would have > done a mergejoin. This is odd if we assume that the lower() > outputs are just text. But you haven't said anyt

Re: Different execution plan between PostgreSQL 8.2 and 12.5

2022-08-17 Thread Tom Lane
gzh writes: > I run following sql in PostgreSQL 8.2 and PostgreSQL 12.5, it returns > different execution plan. 8.2 is ... well, not stone age maybe, but pretty durn ancient. You really ought to update a bit more often than that. (And maybe pay more attention to staying up to date with minor re

Different execution plan between PostgreSQL 8.2 and 12.5

2022-08-17 Thread gzh
Hi, I have had a Perl Website working for 7 years and have had no problems until a few weeks ago I replaced my database server with a newer one. Database server (old): PostgreSQL 8.2 32bit Database server (new): PostgreSQL 12.5 64bit I run following sql in PostgreSQL 8.2 and PostgreS