Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uz9KT-00HNNk-IU for pgsql-performance@arkaria.postgresql.org; Thu, 18 Sep 2025 07:45:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uz9KS-00EZHL-6W for pgsql-performance@arkaria.postgresql.org; Thu, 18 Sep 2025 07:45:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with utf8esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uz9KR-00EZHD-TG for pgsql-performance@lists.postgresql.org; Thu, 18 Sep 2025 07:45:19 +0000 Received: from facteur.thefreecat.org ([212.129.38.6]) by makus.postgresql.org with utf8esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uz9KO-00133o-39 for pgsql-performance@lists.postgresql.org; Thu, 18 Sep 2025 07:45:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thefreecat.org; s=thefreecat; t=1758181513; bh=5DV+NWnu42cpWApQnxQDiCRq06t5g7TLBzQXIBN/wDw=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=Bba2xqCgqCGfgx0NqdJZ3BZ0FAW1lfkeXFhxtrHYTQEvpp3+J5ZHPeWscTM4TihiR 7sm/njz8gDxgUKbANUYOjZOmQ+fIuUJEdjIdHUQlH85wF5PgEXC2saX8cOfpcmyNEF hTWF4gD0ck0/FWiglAR9swqT1ZFqldsG85jLfQHz2uxTX93OUkvAQGijsIHrs Original-Subject: Re: Why isn't PG using an index-only scan? Original-From: Jean-Christophe BOGGIO Original-Cc: "pgsql-performance@lists.postgresql.org" Received: from [192.168.1.182] (91-167-190-143.subs.proxad.net [::ffff:91.167.190.143]) (AUTH: LOGIN cat, TLS: TLS1.3,128bits,ECDHE_RSA_AES_128_GCM_SHA256) by facteur.thefreecat.org with ESMTPSA id 0000000009DC06D4.0000000068CBB889.002F895C; Thu, 18 Sep 2025 09:45:13 +0200 Message-ID: <63d65775-0130-4c5c-a151-8d7728b6d4e8@thefreecat.org> Date: Thu, 18 Sep 2025 09:45:13 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Why isn't PG using an index-only scan? To: David Rowley Cc: "pgsql-performance@lists.postgresql.org" References: <8f25c08c-acb2-47ca-b8c1-6664fc31a361@thefreecat.org> Content-Language: en-US, fr From: Jean-Christophe BOGGIO In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thanks David, Le 18/09/2025 à 09:20, David Rowley a écrit : > Yes. Since *all* records of "oeu" are required and they're not > required in any particular order, then Seq Scan should be the fastest > way to access those records. Ok but then why is it doing it on the AD table? Is it because of the number of rows? > 5 hours seems very slow for the estimated number of records. Have you > tried running the SELECT using EXPLAIN ANALYZE without the INSERT > part? Even if the 84 million Merge Join row estimate is accurate, 5 > hours seems excessively long. I tried this, it took 1 second. And then I discovered that I had an old trigger on the copyrightad table. The insert took 2 seconds. Very sorry for wasting your time and thanks again for putting me on the right track. Have a great day!