mirror of
https://github.com/postgres/postgres.git
synced 2025-06-04 00:02:37 -04:00
Use PREPARE/EXECUTE for repetitive per-object queries in pg_dump.
For objects such as functions, pg_dump issues the same secondary data-collection query against each object to be dumped. This can't readily be refactored to avoid the repetitive queries, but we can PREPARE these queries to reduce planning costs. This patch applies the idea to functions, aggregates, operators, and data types. While it could be carried further, the remaining sorts of objects aren't likely to appear in typical databases enough times to be worth worrying over. Moreover, doing the PREPARE is likely to be a net loss if there aren't at least some dozens of objects to apply the prepared query to. Discussion: https://postgr.es/m/7d7eb6128f40401d81b3b7a898b6b4de@W2012-02.nidsa.loc
This commit is contained in:
parent
9895961529
commit
be85727a3d
@ -58,6 +58,23 @@ typedef enum _teSection
|
||||
SECTION_POST_DATA /* stuff to be processed after data */
|
||||
} teSection;
|
||||
|
||||
/* We need one enum entry per prepared query in pg_dump */
|
||||
enum _dumpPreparedQueries
|
||||
{
|
||||
PREPQUERY_DUMPAGG,
|
||||
PREPQUERY_DUMPBASETYPE,
|
||||
PREPQUERY_DUMPCOMPOSITETYPE,
|
||||
PREPQUERY_DUMPDOMAIN,
|
||||
PREPQUERY_DUMPENUMTYPE,
|
||||
PREPQUERY_DUMPFUNC,
|
||||
PREPQUERY_DUMPOPR,
|
||||
PREPQUERY_DUMPRANGETYPE,
|
||||
PREPQUERY_DUMPTABLEATTACH,
|
||||
PREPQUERY_GETCOLUMNACLS,
|
||||
PREPQUERY_GETDOMAINCONSTRAINTS,
|
||||
NUM_PREP_QUERIES /* must be last */
|
||||
};
|
||||
|
||||
/* Parameters needed by ConnectDatabase; same for dump and restore */
|
||||
typedef struct _connParams
|
||||
{
|
||||
@ -214,6 +231,9 @@ typedef struct Archive
|
||||
bool exit_on_error; /* whether to exit on SQL errors... */
|
||||
int n_errors; /* number of errors (if no die) */
|
||||
|
||||
/* prepared-query status */
|
||||
bool *is_prepared; /* indexed by enum _dumpPreparedQueries */
|
||||
|
||||
/* The rest is private */
|
||||
} Archive;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user