Re: TABLESAMPLE doesn't actually satisfy the SQL spec, does it?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: TABLESAMPLE doesn't actually satisfy the SQL spec, does it?
Дата
Msg-id 12137.1436723451@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: TABLESAMPLE doesn't actually satisfy the SQL spec, does it?  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: TABLESAMPLE doesn't actually satisfy the SQL spec, does it?  (Simon Riggs <simon@2ndQuadrant.com>)
Список pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> On Sun, Jul 12, 2015 at 12:02 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> As best I can tell (evidence below), the SQL standard requires that if a
>> single query reads a table with a TABLESAMPLE clause multiple times (say,
>> because it's on the inside of a nestloop), then the exact same set of
>> sampled rows are returned each time.

> Hmm, I tend to agree that it would be good if it behaved that way.
> Otherwise, it seems like the behavior could be quite surprising.

Yeah.  As a concrete example, consider
select * from t1, t2 tablesample ... where t1.x = t2.x

and suppose that there are multiple occurences of x = 10 in both tables.
As things stand, if the join is done as a nestloop then a particular t2
row with x = 10 might appear in the output joined with some of the t1 rows
with x = 10 but not with others.  On the other hand, the results of a hash
join would not be inconsistent in that way, since t2 would be read only
once.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: [PATCH] Generalized JSON output functions
Следующее
От: "Shulgin, Oleksandr"
Дата:
Сообщение: Re: [PATCH] Generalized JSON output functions