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 1tqB6r-000gvH-If for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Mar 2025 13:17:58 +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 1tqB6p-00BCxs-C5 for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Mar 2025 13:17:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tqB6o-00BCxQ-Sv for pgsql-hackers@lists.postgresql.org; Thu, 06 Mar 2025 13:17:55 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tqB6i-001IpA-1O for pgsql-hackers@lists.postgresql.org; Thu, 06 Mar 2025 13:17:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1741267064; bh=4lJFrYZQJDGy+Z1QyymJUQ2OCjWgBiz/B+rcKODLkGA=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=hUldxIMcJRagtrl3Cike3FdNQspNmZm+2i/WjyG1Q3DVQL6O2+HRi8GeUy2RMSf7q KWCtMPwAtH4YKS2q8CFT1InkCuuZx3/N7dVEIGLEK1r7xSHtMxedyuQB0dZ/SHwKvx DD4HkSnWjfIlUR+fEWy6KJACSJeqxrmqquLgk5Za2ffw1V+ywekqjDsr5E/qu9pf4J CZahca6Usd2OcXr2Vn8UUAP8Bq/XXtoxk26vLnhMXegZfOrrU+aNY0j64imfyxePCC +zrhUTBfX/Uhw5Wcey+lIVl0/XmKZzVbEsh15M8yJZ90GkitarvUpUkdFWBubuct9b ZcriI0fQ19Wtw== Received: from [10.4.12.74] (unknown [93.174.131.141]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: a.rybakina@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id 86E8060464; Thu, 6 Mar 2025 16:17:44 +0300 (MSK) Message-ID: Date: Thu, 6 Mar 2025 16:17:44 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: explain analyze rows=%.0f To: Ilia Evdokimov Cc: Robert Haas , Tom Lane , Andrei Lepikhov , pgsql-hackers@lists.postgresql.org, Guillaume Lelarge , Matheus Alcantara References: <01ec86c1-e04b-4cbe-b641-22cae8b87604@tantorlabs.com> <73e2440e-7d8b-4860-974d-931a93326d95@gmail.com> <3737950.1740182671@sss.pgh.pa.us> <3816053.1740190267@sss.pgh.pa.us> <40663fc5-edac-4b45-a2aa-a76976700ed9@tantorlabs.com> Content-Language: en-US From: Alena Rybakina In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/03/06 10:27:00 #27639335 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi! I got a query plan with a strange number of rows. Could you please help me understand it? create temp table ta (id int primary key, val int); create temp table tb (id int primary key, aval int); create temp table tc (id int primary key, aid int); insert into ta select id, id from generate_series(1,1000) as id; insert into tb select id, id from generate_series(500,1000) as id; insert into tc select id, id from generate_series(400,1000) as id; EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF, BUFFERS OFF)  SELECT 1    FROM ta ta1   WHERE EXISTS (SELECT 1                   FROM tb                   JOIN tc                     ON tb.id = ta1.id and                        ta1.id < 1000                     where exists (select 1 from ta ta2 where ta2.id = ta1.id));                                       QUERY PLAN --------------------------------------------------------------------------------------  Seq Scan on ta ta1 (actual rows=500.00 loops=1)    Filter: EXISTS(SubPlan 2)    Rows Removed by Filter: 500    SubPlan 2      ->  Result (actual rows=0.50 loops=1000)            One-Time Filter: ((ta1.id < 1000) AND (InitPlan 1).col1)            InitPlan 1              ->  Index Only Scan using ta_pkey on ta ta2 (actual rows=1.00 loops=999)                    Index Cond: (id = ta1.id)                    Heap Fetches: 999            ->  Nested Loop (actual rows=0.50 loops=999)                  ->  Seq Scan on tb (actual rows=0.50 loops=999)                        Filter: (id = ta1.id)                        Rows Removed by Filter: 375                  ->  Seq Scan on tc (actual rows=1.00 loops=500) (15 rows) To be honest I can't understand why 0.50 number of rows here? -- Regards, Alena Rybakina Postgres Professional