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 1jnS6W-0002eh-5L for pgsql-performance@arkaria.postgresql.org; Mon, 22 Jun 2020 19:27:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jnS6U-0004eD-Q5 for pgsql-performance@arkaria.postgresql.org; Mon, 22 Jun 2020 19:27:38 +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 1jnS6U-0004e6-Dj for pgsql-performance@lists.postgresql.org; Mon, 22 Jun 2020 19:27:38 +0000 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jnS6S-0002Rl-8G for pgsql-performance@lists.postgresql.org; Mon, 22 Jun 2020 19:27:37 +0000 Received: by mail-qk1-x744.google.com with SMTP id l188so3603106qkf.10 for ; Mon, 22 Jun 2020 12:27:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=PYqmP0+ArGvVObvQhk4G3tnO6ZhPKAnfb8cKnxg7q4M=; b=dspz28dluwMos9WKDUTDPoyQ1H1V+4mf5ImAIoBuC+3Y5fu+suLQr2tRl9cdiKLkbD 2wtseMHLznxk6GnSYOIlApELFYP1mXP/kCQktWtQwaYiG8MYZTYHecRkQZYBEftiy3IX kG2M3Dmrc3OaSPzWmPzm4Xi7+5JyiNdD8SlWXZ48lY0naA6KHoyXr4EQXMsN0frSI9WY U2uaOR59dS0hZrp36zVpa90w76fhqy9yAcKn2GihACjH6I5puKwZYdFijB8zV3LiRmmR oVxmAcszAWUpCjI+Dos1EiBwjt5bFIZ1DD4h+PwEcUqe7Jael9w6iL5PW1ItW5sss+yf 1jUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=PYqmP0+ArGvVObvQhk4G3tnO6ZhPKAnfb8cKnxg7q4M=; b=bWoqbmyHpfq7a3TOvYti2g4aBMF933EPXGj5CPMK343v5X9neekrBU88AlXXw/eysp G7hdjwF6A1kWPq1ixoQdXaxWfpkS1Dk/Wv7+4CrgJRJnTlPXJUzx1FFJXSpkLl1W8FbT vu24H+hKdXfRgtxxxL9BPtFx2beGa9c2BzF313rTKUiYrUkOBO0EeNCLYTxHcAiGjIsv OvqP4SE50XgTmJW/wCTVWhJY9AALR5JwKosShWjiwtJofjAlusMWd9xVjRKN+ZBs3BEy Zr4m1v1ewOZmFL6cyPmcaq7iLcG/5EIy3hKTuXX71g3iYqb+Ro+S1jVFj0dQiAGHJAuq d2xA== X-Gm-Message-State: AOAM530Nejjb0AaT9NiHoov8ohsBGToA4qd8pQ+Q4vlBw5qb+K5JeMZA BZ29G7Ne4W8DTGmAoCV35ApZWzmqMEC0qSa8Zq5vMQ9iCKfuKEB81leD9Rosm1SjDABNMfqr/xp KytEDTvHkZDunjYm4BQjxwB5jCcJFeqlvd/l70IDBdQqMTxpe0vyt54w2RAqlRE9g5QlmntGklI tHXgH7pXM5IpHUJJONtj8= X-Google-Smtp-Source: ABdhPJz2enhAgR5pK2gPtd3hwJlwhHcVfiJ7BznobolSNxMBHLjRIX2a7lqIcyvdkgrYZ6pjc6Nd1g== X-Received: by 2002:a37:4048:: with SMTP id n69mr16621545qka.344.1592854055132; Mon, 22 Jun 2020 12:27:35 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id 19sm11795454qke.44.2020.06.22.12.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jun 2020 12:27:34 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 8AEB62A3A2C; Mon, 22 Jun 2020 15:27:32 -0400 (-04) Date: Mon, 22 Jun 2020 15:27:32 -0400 From: Alvaro Herrera To: Tom Lane Cc: Kenneth Marshall , pgsql-performance@lists.postgresql.org Subject: Re: PostgreSQL 12.3 slow index scan chosen Message-ID: <20200622192732.GA29072@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1815407.1592677323@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services