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 1nCjtY-00041j-04 for pgsql-general@arkaria.postgresql.org; Wed, 26 Jan 2022 15:07:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nCjtW-0003t7-Sf for pgsql-general@arkaria.postgresql.org; Wed, 26 Jan 2022 15:07:34 +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 1nCjtW-0003sv-I1 for pgsql-general@lists.postgresql.org; Wed, 26 Jan 2022 15:07:34 +0000 Received: from ms-10.1blu.de ([178.254.4.101]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nCjtT-0002BC-WE for pgsql-general@lists.postgresql.org; Wed, 26 Jan 2022 15:07:33 +0000 Received: from [188.174.53.237] (helo=localhost.unixarea.de) by ms-10.1blu.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCjtR-00064B-Jn; Wed, 26 Jan 2022 16:07:29 +0100 Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.unixarea.de (8.16.1/8.14.9) with ESMTPS id 20QF7SHM030229 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 26 Jan 2022 16:07:28 +0100 (CET) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.16.1/8.14.9/Submit) id 20QF7S24030228; Wed, 26 Jan 2022 16:07:28 +0100 (CET) (envelope-from guru@unixarea.de) X-Authentication-Warning: localhost.my.domain: guru set sender to guru@unixarea.de using -f Date: Wed, 26 Jan 2022 16:07:28 +0100 From: Matthias Apitz To: Julien Rouhaud Cc: Dominique Devienne , Matthias Apitz , Josef =?utf-8?B?xaBpbcOhbmVr?= , pgsql-general Subject: Re: SELECT with LIKE clause makes full table scan Message-ID: Reply-To: Matthias Apitz References: <20220126121306.k6ilsxl7vy2ppmjn@jrouhaud> <20220126135139.uik5gbuzyxybxq4x@jrouhaud> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220126135139.uik5gbuzyxybxq4x@jrouhaud> X-Operating-System: FreeBSD 13.0-CURRENT r368166 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 188.174.53.237 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk We changed two relevant Indexes to CREATE INDEX d01ort ON d01buch(d01ort bpchar_pattern_ops ); CREATE INDEX d01ort2 ON d01buch(d01ort2 bpchar_pattern_ops ); and now the same queries are fast. We're looking through our code for more such LIKE clauses on VCHAR columns. Thanks for all the hints matthias -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub