Re: Functions and Indexes - Mailing list pgsql-general

From Laurenz Albe
Subject Re: Functions and Indexes
Date
Msg-id 40c19c0217025001681c78a7b65f30bc02ea57fc.camel@cybertec.at
Whole thread Raw
In response to Re: Functions and Indexes  (Moreno Andreo <moreno.andreo@evolu-s.it>)
List 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'thold 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



pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: PostgreSQL 15.9 Update: Partitioned tables with foreign key constraints
Next
From: Paul Foerster
Date:
Subject: Re: PostgreSQL 15.9 Update: Partitioned tables with foreign key constraints