Re: Cursor With_Hold Performance Workarounds/Optimization

From: David Fetter <david(at)fetter(dot)org>
To: Leon Winter <winter-pg(at)bfw-online(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Cursor With_Hold Performance Workarounds/Optimization
Date: 2017-10-19 13:54:32
Message-ID: 20171019135432.GJ11738@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Oct 19, 2017 at 03:20:48PM +0200, Leon Winter wrote:
> Hi,
>
> I originally brought up this issue on the pgsql-performance mailing list [^] to
> no avail so I am trying again here.
>
> During implementation of a runtime environment and the adjoining database
> abstraction layer I noticed (like many before me [0] and as correctly mentioned
> in the documentation) the sizeable performance impact of declaring a cursor
> "with hold" for queries with large result sets.
>
> Our use case very often looks like this:
>
> open cursor for select from table1
> loop
> { fetch some entries from cursor
> update table2
> commit
> }

This seems like a very odd construct based on ideas about databases
that aren't actually true of PostgreSQL, e.g. that joins are
expensive, or that some substantial benefit comes of committing at
some higher frequency than the logical transaction.

What other things did you try, and how did they fail? In particular,
what happened when you used

UPDATE table2
SET [things based on table1]
FROM table1 [qualified] JOIN table2 ON ([conditions])

Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Leon Winter 2017-10-19 14:06:47 Re: Cursor With_Hold Performance Workarounds/Optimization
Previous Message Leon Winter 2017-10-19 13:20:48 Cursor With_Hold Performance Workarounds/Optimization