Re: Merge David and Goliath tables efficiently

Поиск
Список
Период
Сортировка
От Tomas Vondra
Тема Re: Merge David and Goliath tables efficiently
Дата
Msg-id 36cb9fe9-b792-2345-65ed-586de44a48b9@enterprisedb.com
обсуждение исходный текст
Ответ на Re: Merge David and Goliath tables efficiently  (nicolas paris <nicolas.paris@riseup.net>)
Ответы Re: Merge David and Goliath tables efficiently  (nicolas paris <nicolas.paris@riseup.net>)
Список pgsql-performance
On 6/19/23 14:20, nicolas paris wrote:
>> IMHO the thing that breaks it is the ORDER BY in the merge, which
>> likely
>> acts as an optimization fence and prevents all sorts of smart things
>> including the partitionwise join. I'd bet that if Nicolas replaces
>>
>>   MERGE INTO "goliath" ca
>>   USING (SELECT * FROM "david" ORDER BY "list_id") AS t
>>   .
> 
> Sorry if it was not clear, however there is no order by in the 2.1
> strategy. Then this cannot be the reason of not triggering the optim.
> 
> For information I do enable partition join feature with jdbc call just
> before the merge:
> set enable_partitionwise_join=true
> 

But you wrote that in both cases the query is:

    MERGE INTO "goliath" ca
    USING (SELECT * FROM "david" ORDER BY "list_id") AS t
    ON t."list_id" = ca."list_id"
    WHEN MATCHED THEN
    UPDATE SET ...
    WHEN NOT MATCHED THEN
    INSERT (...)
    VALUES (...)

With all due respect, I'm getting a bit tired of having to speculate
about what exactly you're doing etc. based on bits of information.

I'm willing to continue to investigate, but only if you prepare a
reproducer, i.e. a SQL script that demonstrates the issue - I don't
think preparing that should be difficult, something like the SQL script
I shared earlier today should do the trick.

I suggest you do that directly, not through JDBC. Perhaps the JDBC
connection pool does something funny (like connection pooling and
resetting settings).


regards

-- 
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



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

Предыдущее
От: nicolas paris
Дата:
Сообщение: Re: Merge David and Goliath tables efficiently
Следующее
От: nicolas paris
Дата:
Сообщение: Re: Merge David and Goliath tables efficiently