Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVHB2-0007i3-86 for pgsql-performance@arkaria.postgresql.org; Tue, 28 Sep 2021 17:46:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mVHAU-0007Tn-GK for pgsql-performance@arkaria.postgresql.org; Tue, 28 Sep 2021 17:45:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVHAU-0007Tf-70 for pgsql-performance@lists.postgresql.org; Tue, 28 Sep 2021 17:45:26 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mVHAN-0004cW-Qy for pgsql-performance@lists.postgresql.org; Tue, 28 Sep 2021 17:45:25 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 18SHjGx22853353; Tue, 28 Sep 2021 13:45:16 -0400 From: Tom Lane To: Daniel Diniz cc: "pgsql-performance@lists.postgresql.org" Subject: Re: Problem with indices from 10 to 13 In-reply-to: References: <8d2ba21d-2318-4f02-a8fd-04c7d97e22ab.e854021a-9da0-4eba-a51f-e5ff782985ef.17ca0caa-f521-44ce-817a-17cbc713d135@emailsignatures365.codetwo.com> Comments: In-reply-to Daniel Diniz message dated "Tue, 28 Sep 2021 15:39:52 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2853351.1632851116.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 28 Sep 2021 13:45:16 -0400 Message-ID: <2853352.1632851116@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Daniel Diniz writes: > Hello I migrated from postgres 10 to 13 and I noticed that there was a b= ig increase in a querie that I use, I did explain in 10 and 13 and the dif= ference is absurd, the indices and data are the same in 2. I've re-created= and re-indexed but I don't know what changed from 10 to 13 which made the= performance so bad, I don't know if it needs some extra parameter in some= conf on 13. This complaint is missing an awful lot of supporting information. > " -> Bitmap Heap Scan on hawbs h (cost=3D= 1058.34..26261.32 rows=3D21451 width=3D46) (actual time=3D201.956..201.966= rows=3D4 loops=3D1)" > " Recheck Cond: ((nome_des)::text ~= ~* convert_from('\x255354455048414e592053544f4557204c45414e44524f25'::byte= a, 'LATIN1'::name))" > " Filter: (tipo_hawb_id =3D ANY ('{= 1,10,3}'::integer[]))" > " Heap Blocks: exact=3D4" > " -> Bitmap Index Scan on idx_nome= _des (cost=3D0.00..1052.98 rows=3D22623 width=3D0) (actual time=3D201.942= ..201.943 rows=3D4 loops=3D1)" > " Index Cond: ((nome_des)::te= xt ~~* convert_from('\x255354455048414e592053544f4557204c45414e44524f25'::= bytea, 'LATIN1'::name))" For starters, how in the world did you get that query condition out of > where h.nome_des ilike '%STEPHANY STOEW LEANDRO%' ? What data type is h.nome_des, anyway? And what kind of index is that --- it couldn't be a plain btree, because we wouldn't consider ~~* to be indexable by a btree. However, the long and the short of it is that this rowcount estimate is off by nearly four orders of magnitude (21451 estimated vs. 4 actual is pretty awful). It's probably just luck that you got an acceptable plan out of v10, and bad luck that you didn't get one out of v13 --- v13's estimate is not better, but it's not much worse either. You need to do something about improving that estimate if you'd like reliable query planning. Since I'm not too sure which operator you're actually invoking, it's hard to offer good advice about how hard that might be. regards, tom lane