public inbox for [email protected]  
help / color / mirror / Atom feed
From: Laurenz Albe <[email protected]>
To: Moreno Andreo <[email protected]>
To: [email protected]
Subject: Re: Functions and Indexes
Date: Tue, 19 Nov 2024 18:44:03 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>

On Tue, 2024-11-19 at 14:30 +0100, Moreno Andreo wrote:
> Inhttps://www.cybertec-postgresql.com/en/join-strategies-and-performance-in-postgresql/
>  you say 
>  "Note that for inner joins there is no distinction between the join condition and the WHERE condition, but that doesn't hold for outer joins."
>  What do you mean?

CREATE TABLE a (id integer);

INSERT INTO a VALUES (1), (2), (3);

CREATE TABLE b (id integer);

INSERT INTO b VALUES (1), (2), (4);

SELECT * FROM a JOIN b ON a.id = b.id AND b.id < 2;
 id │ id 
════╪════
  1 │  1
(1 row)

SELECT * FROM a JOIN b ON a.id = b.id WHERE b.id < 2;
 id │ id 
════╪════
  1 │  1
(1 row)

SELECT * FROM a LEFT JOIN b ON a.id = b.id AND b.id < 2;
 id │ id 
════╪════
  1 │  1
  2 │  ∅
  3 │  ∅
(3 rows)

SELECT * FROM a LEFT JOIN b ON a.id = b.id WHERE b.id < 2;
 id │ id 
════╪════
  1 │  1
(1 row)

Yours,
Laurenz Albe






view thread (3+ 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: Functions and Indexes
  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