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 1jnS7z-0002iE-5b for pgsql-performance@arkaria.postgresql.org; Mon, 22 Jun 2020 19:29:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jnS7y-0000Xd-1R for pgsql-performance@arkaria.postgresql.org; Mon, 22 Jun 2020 19:29:10 +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 1jnS7x-0000XW-QZ for pgsql-performance@lists.postgresql.org; Mon, 22 Jun 2020 19:29:09 +0000 Received: from aart.rice.edu ([168.7.56.48]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jnS7v-0002So-1M for pgsql-performance@lists.postgresql.org; Mon, 22 Jun 2020 19:29:08 +0000 Received: by aart.rice.edu (Postfix, from userid 18612) id 47847427F342; Mon, 22 Jun 2020 14:29:06 -0500 (CDT) Date: Mon, 22 Jun 2020 14:29:06 -0500 From: Kenneth Marshall To: Alvaro Herrera Cc: Tom Lane , pgsql-performance@lists.postgresql.org Subject: Re: PostgreSQL 12.3 slow index scan chosen Message-ID: <20200622192906.GD1497@aart.rice.edu> References: <1815407.1592677323@sss.pgh.pa.us> <20200622192732.GA29072@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200622192732.GA29072@alvherre.pgsql> User-Agent: Mutt/1.5.21 (2010-09-15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Jun 22, 2020 at 03:27:32PM -0400, Alvaro Herrera wrote: > On 2020-Jun-20, Tom Lane wrote: > > > I wrote: > > > ... oh, now I see: apparently, your filter condition is such that *no* > > > rows of the objectcustomfieldvalues table get past the filter: > > > > > > -> Index Scan using objectcustomfieldvalues3 on objectcustomfieldvalues objectcustomfieldvalues_1 (cost=0.56..807603.40 rows=915 width=4) (actual time=21165.441..21165.441 rows=0 loops=1) > > > Filter: ((disabled = 0) AND ((largecontent ~~* '%958575%'::text) OR ((content)::text ~~* '%958575%'::text))) > > > Rows Removed by Filter: 19030904 > > > You said you'd increased the stats target for > > objectcustomfieldvalues.objectid, but maybe the real problem is needing > > to increase the targets for content and largecontent, in hopes of driving > > down the estimate for how many rows will pass this filter condition. > > ... but those on content and largecontent are unanchored conditions -- > are we still able to do any cardinality analysis using those? I thought > not. Maybe a trigram search would help? See contrib/pg_trgm -- as far > as I remember that module is able to work with LIKE conditions. > Hi Alvaro, I do have a pg_trgm GIN index on those fields for the search. Regards, Ken