Re: improve performance of pg_dump with many sequences - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: improve performance of pg_dump with many sequences
Date
Msg-id ZpiP3I6UVcgsCCWf@nathan
Whole thread Raw
In response to Re: improve performance of pg_dump with many sequences  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: improve performance of pg_dump with many sequences
List pgsql-hackers
Here is an attempt at adding a new function that returns the sequence tuple
and using that to avoid querying each sequence relation individually in
dumpSequenceData().

If we instead wanted to change pg_sequence_last_value() to return both
is_called and last_value, I think we could modify the pg_sequences system
view to use a LATERAL subquery, i.e.,

    SELECT
        ...
        CASE
            WHEN L.is_called THEN L.last_value
            ELSE NULL
        END AS last_value
    FROM pg_sequence S
        ...
        JOIN LATERAL pg_sequence_last_value(S.seqrelid) L ON true
    ...

That doesn't seem so bad, and it'd avoid an extra pg_proc entry, but it
would probably break anything that calls pg_sequence_last_value() directly.
Thoughts?

-- 
nathan

Attachment

pgsql-hackers by date:

Previous
From: Paul Jungwirth
Date:
Subject: Re: SQL:2011 application time
Next
From: shveta malik
Date:
Subject: Re: Allow logical failover slots to wait on synchronous replication