public inbox for [email protected]
help / color / mirror / Atom feedFrom: Alena Rybakina <[email protected]>
To: Ilia Evdokimov <[email protected]>
Cc: Robert Haas <[email protected]>
Cc: Tom Lane <[email protected]>
Cc: Andrei Lepikhov <[email protected]>
Cc: [email protected]
Cc: Guillaume Lelarge <[email protected]>
Cc: Matheus Alcantara <[email protected]>
Subject: Re: explain analyze rows=%.0f
Date: Thu, 6 Mar 2025 16:17:44 +0300
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <CA+TgmoZv8DvmeQHQAX+rkn68id2N+DoUhFZB36d-_w1tyAeqeA@mail.gmail.com>
<CA+TgmobfeePej0uNfbLy0v6jUrB3D9m1Kh+QQ40_-A9KQjkqUw@mail.gmail.com>
<[email protected]>
<[email protected]>
<CA+TgmobVWYnYDj1HZ--iqeKx+n7zTgtYCar+YfZ0V6wiX-t0Mg@mail.gmail.com>
<[email protected]>
<CA+Tgmoaob_3aNF5S49WFoJs6Rb37rNnd5WH_e9nXAn_jtWWCLQ@mail.gmail.com>
<[email protected]>
<CA+TgmobXwtS0ncAVfukE-Uhhy8Zt5rQWwQb2WHBcSop8r4Lcgw@mail.gmail.com>
<[email protected]>
<CA+TgmoZp7LstKmDwyfUuB+6aFFhn0N3fv2QxTD=dkrxXVJ5dZA@mail.gmail.com>
<CA+TgmoazzVHn8sFOMFAEwoqBTDxKT45D7mvkyeHgqtoD2cn58Q@mail.gmail.com>
<[email protected]>
<CA+TgmoZxRP8cEhfdF27k600B_=8DXpj=8kiM7s_6qCHCqxQPmA@mail.gmail.com>
<CA+TgmoapgkOFmezwVjJbs5Xq9F+Mfm9aNouBgTq_AuqQJkLYEg@mail.gmail.com>
<[email protected]>
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
view thread (38+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: explain analyze rows=%.0f
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox