Search Postgresql Archives

Re: Functions and Indexes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux