Re: [GENERAL] is (not) distinct from
От | Tom Lane |
---|---|
Тема | Re: [GENERAL] is (not) distinct from |
Дата | |
Msg-id | 1318.1488384749@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: [GENERAL] is (not) distinct from (Adrian Klaver <adrian.klaver@aklaver.com>) |
Ответы |
Re: [GENERAL] is (not) distinct from
|
Список | pgsql-general |
Adrian Klaver <adrian.klaver@aklaver.com> writes: > Where I am going with this, is that it is not clear to me how you are > matching the two sets of records to determine whether they are different > or not. He's not. The query is forming the cartesian product of the two tables and then dropping join rows where the tables match ... but every B row is going to have multiple A rows where it doesn't match, and those join rows will all survive the WHERE. Then "select distinct" gets rid of the duplicates, and since nothing from A is presented in the result, it's not very obvious what's happening. This is a great example of "select distinct" being used as a band-aid over a fundamental misunderstanding of SQL. It's good advice to never use "distinct" unless you know exactly why your query is generating duplicate rows in the first place. regards, tom lane
В списке pgsql-general по дате отправления: