Re: Functions and Indexes

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Moreno Andreo <moreno(dot)andreo(at)evolu-s(dot)it>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Functions and Indexes
Date: 2024-11-19 17:44:03
Message-ID: 40c19c0217025001681c78a7b65f30bc02ea57fc.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michel Pelletier 2024-11-19 17:50:29 Re: Using Expanded Objects other than Arrays from plpgsql
Previous Message Alvaro Herrera 2024-11-19 16:34:03 Re: PostgreSQL 15.9 Update: Partitioned tables with foreign key constraints