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 1sj2Gv-00DAbY-56 for pgsql-general@arkaria.postgresql.org; Tue, 27 Aug 2024 19:54:35 +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 1sj2Gt-00Bz3R-94 for pgsql-general@arkaria.postgresql.org; Tue, 27 Aug 2024 19:54:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with utf8esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sj2Gs-00Bz0i-RS for pgsql-general@lists.postgresql.org; Tue, 27 Aug 2024 19:54:31 +0000 Received: from facteur.thefreecat.org ([212.129.38.6]) by magus.postgresql.org with utf8esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sj2Gp-001oC1-Sn for pgsql-general@lists.postgresql.org; Tue, 27 Aug 2024 19:54:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thefreecat.org; s=thefreecat; t=1724788466; bh=ENOdoc2WN4RDgY2JgMRlXNOB+OLoY6u5xpafMI8Kkgg=; h=Date:Subject:To:References:From:In-Reply-To; b=Dk1iwkGD4COsJt9yWdOIMqg4jgsxSKvbIBowboIaNfRGsSf9+W0NTnRLTzUqTI/YB CisYmTwyI0Zasyg+C0yUJ/nWOfXVFrmmgsbsz7QkjKgOgwfW6mT5Y3aCt3htNJohqp +aGm9oWiX4SJpwWD+AGQtUWC3TXuH5fAcGAdOV+c7ctS1gCeoh/S6Nlqw14o2 Original-Subject: Re: Strange behaviors with ranges Original-From: Jean-Christophe BOGGIO 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.0000000066CE2EF2.00017C52; Tue, 27 Aug 2024 21:54:26 +0200 Message-ID: <6f6df414-625d-4c3e-8b9e-b772a376c149@thefreecat.org> Date: Tue, 27 Aug 2024 21:54:24 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Strange behaviors with ranges To: Paul Jungwirth , pgsql-general@lists.postgresql.org References: <77691006-45f1-4ef9-bc1b-2eecd44f7d0d@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 Paul, Le 27/08/2024 à 20:11, Paul Jungwirth a écrit : > The issue is the order-of-operations used by the planner. If I put > EXPLAIN on your last query, I see: > >  Hash Join  (cost=16.64..109.90 rows=2410 width=64) >    Hash Cond: (tmp_limitcontrats.idcontrat = paliers.idcontrat) >    ->  Seq Scan on tmp_limitcontrats  (cost=0.00..35.50 rows=2550 > width=4) >    ->  Hash  (cost=14.27..14.27 rows=189 width=12) >          ->  Seq Scan on paliers  (cost=0.00..14.27 rows=189 width=12) >                Filter: (numrange(((qtep1 + 1))::numeric, > (qtep2)::numeric) <> '(,)'::numrange) > > So we are applying that filter to every row in paliers, not just the > one with idcontrat = 1003. I understand, makes perfect sense. Thanks for the explanation. Have a nice day,