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 1nCkDw-0004eX-KC for pgsql-general@arkaria.postgresql.org; Wed, 26 Jan 2022 15:28: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 1nCkDv-0000xZ-9a for pgsql-general@arkaria.postgresql.org; Wed, 26 Jan 2022 15:28:39 +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 1nCkDu-0000xQ-Ve for pgsql-general@lists.postgresql.org; Wed, 26 Jan 2022 15:28:38 +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 1nCkDs-0002K1-Dd for pgsql-general@lists.postgresql.org; Wed, 26 Jan 2022 15:28:37 +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 1nCkDq-0002Jv-Pj; Wed, 26 Jan 2022 16:28:34 +0100 Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.unixarea.de (8.16.1/8.14.9) with ESMTPS id 20QFSXUe031775 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 26 Jan 2022 16:28:34 +0100 (CET) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.16.1/8.14.9/Submit) id 20QFSXif031774; Wed, 26 Jan 2022 16:28:33 +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:28:33 +0100 From: Matthias Apitz To: Julien Rouhaud Cc: Matthias Apitz , Dominique Devienne , 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: 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 El día miércoles, enero 26, 2022 a las 11:21:12p. m. +0800, Julien Rouhaud escribió: > Hi, > > On Wed, Jan 26, 2022 at 11:07 PM Matthias Apitz wrote: > > > > We changed two relevant Indexes to > > > > CREATE INDEX d01ort ON d01buch(d01ort bpchar_pattern_ops ); > > CREATE INDEX d01ort2 ON d01buch(d01ort2 bpchar_pattern_ops ); > > When you said changed, did you drop the previous ones? Yes, of course. > As Tom > mentioned, those indexes are specialized and are only useful for LIKE > 'something%' queries. It's quite likely that your existing indexes > were useful for other queries, which may not be as fast without those > indexes. You can check in pg_stat_user_indexes if your indexes seems > to be used before actually dropping them for instance: > https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ALL-INDEXES-VIEW Thanks, we're still investigating more cases with LIKE clause and will consider your hint. matthias -- Matthias Apitz, ✉ guru@unixarea.de, http://www.unixarea.de/ +49-176-38902045 Public GnuPG key: http://www.unixarea.de/key.pub