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 1jgsxs-0005mU-UU for pgsql-general@arkaria.postgresql.org; Thu, 04 Jun 2020 16:43: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 1jgsxr-0005xA-QM for pgsql-general@arkaria.postgresql.org; Thu, 04 Jun 2020 16:43:35 +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 1jgsxr-0005x3-Il for pgsql-general@lists.postgresql.org; Thu, 04 Jun 2020 16:43:35 +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 1jgsxp-0001pl-Jn for pgsql-general@lists.postgresql.org; Thu, 04 Jun 2020 16:43:34 +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 054GhW5s1251079; Thu, 4 Jun 2020 12:43:32 -0400 From: Tom Lane To: Koen De Groote cc: pgsql-general@lists.postgresql.org Subject: Re: Index no longer being used, destroying and recreating it restores use. In-reply-to: References: Comments: In-reply-to Koen De Groote message dated "Thu, 04 Jun 2020 17:37:38 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1251077.1591289012.1@sss.pgh.pa.us> Date: Thu, 04 Jun 2020 12:43:32 -0400 Message-ID: <1251078.1591289012@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Koen De Groote writes: > I've got a table with about 30 million rows and a particular index that up > until recently was actively being used. > And then it stopped being used and the query that the index was made for, > is now doing sequential scans. > Deleting the index and creating it again, seems to fix the problem. The new > index, which is identical in composition, is being used and the query in > question no longer uses sequential scans. It's possible that the index had bloated to the point where the planner thought it was cheaper to use a seqscan. Did you make a note of the cost estimates for the different plans? regards, tom lane