public inbox for [email protected]
help / color / mirror / Atom feedFrom: Tom Lane <[email protected]>
To: Greg Rychlewski <[email protected]>
Cc: [email protected]
Subject: Re: nested loop joins
Date: Tue, 26 Oct 2021 14:56:12 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAKemG7Xi_3eS+wT97ENWbzAmpwoVHJ5=YbQQcnswo5G5qHaNMw@mail.gmail.com>
References: <CAKemG7Xi_3eS+wT97ENWbzAmpwoVHJ5=YbQQcnswo5G5qHaNMw@mail.gmail.com>
Greg Rychlewski <[email protected]> writes:
> I'm looking to understand how nested loop joins with limits work. Say I
> have this query
> SELECT *
> FROM a INNER JOIN b ON a.id = b.id
> LIMIT 10;
> Say this was done as a nested loop join where the rows of "a" are the outer
> loop.
> In this scenario, would all the rows of "a" be materialized or are they
> lazily evaluated?
Evaluation of the join will stop as soon as it's produced 10 rows.
Only as much of "a" will be read as necessary to get that.
(Potentially, not all of "b" would be read either, if 10 matches
to the first "a" row exist in "b".)
regards, tom lane
view thread (2+ messages)
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]
Subject: Re: nested loop joins
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