Re: Functions and Indexes

Поиск
Список
Период
Сортировка
От Laurenz Albe
Тема Re: Functions and Indexes
Дата
Msg-id 40c19c0217025001681c78a7b65f30bc02ea57fc.camel@cybertec.at
обсуждение исходный текст
Ответ на Re: Functions and Indexes  (Moreno Andreo <moreno.andreo@evolu-s.it>)
Список 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 по дате отправления: