gzh <gzhcoder@xxxxxxx> writes: > I run following sql in PostgreSQL 8.4 and PostgreSQL 12.11, it returns different execution plan. Have you done an ANALYZE in the new database? The rowcount estimates seem a lot different, leading me to guess that the newer installation doesn't have good statistics yet. regards, tom lane