Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1juUrI-0000VU-O1 for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Jul 2020 05:49:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1juUrG-0005Vr-Ch for pgsql-hackers@arkaria.postgresql.org; Sun, 12 Jul 2020 05:49:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1juUrG-0005Vk-33 for pgsql-hackers@lists.postgresql.org; Sun, 12 Jul 2020 05:49:02 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1juUr9-0003vR-Hp for pgsql-hackers@lists.postgresql.org; Sun, 12 Jul 2020 05:49:00 +0000 Received: by mail-wr1-x42b.google.com with SMTP id f18so9737310wrs.0 for ; Sat, 11 Jul 2020 22:48:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition; bh=Im7pFM6FNK7dn4voQ1AuViSgRCT4QMfE2Z34bzSG3HQ=; b=TYu3wlI6/cfJxVsN77J0qhb53gqmRpV5vkw2Bm+xgV3ootBshsvew402EzCrSDs6yk qC5wLpI5saCrL+HA45yO3Jvb5ykfdbbsbuWEDWjSm8JDho4acfcEBuoXL8lskNTw/3CZ J2D8vDQwTUNxkk3XsGuPxfLll+Sq3DrRay81GyZsVphnv8cPwMCVwrly3KppDWWO8UQi 7acfMSRWdpR6HQmOiWxnvpCDuHC968lxz+PjtVPhm7h2sTQA/bItfW4amJFT6oxeR10z ANnJ8rwAhNnPepZYN8UkaazMKPkTef2jTUubWSe52HnFq1+UvZjKmq9db2+JHG+Fzg6i NABw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=Im7pFM6FNK7dn4voQ1AuViSgRCT4QMfE2Z34bzSG3HQ=; b=YsOtdbjfIDkH4EqBwIZMXP5VbS7jBuyWWhOIgFxgDOLeXST8RKTIK2BgJtrI0s5Q7S YclqcwiER+aczxniYCrMqzkaouV+L/mvp9pc28ejeDVQH00yfrSD+Q9fecOQNJ15DfSA ThSFvYkRmwy8CIKVmhgl75Xmwi71Wm+4w4SeBRrwRickfWj7mg744oSXlUu0nxTj5NhD 3yiyOlhG9Ak4c3BJGGUNiz1pq7FqgdNiwzwCqeWO7ssbu2p/ODILETAd9u1CR77qh6rY 3VpGqDrl4xDcTdcvTRQMr2sgYmWis616mIqpKCrxpuW/zAqr8Mi2/57kC/TX6WhcSDob Jn8A== X-Gm-Message-State: AOAM533gYRNnYhDEGDi083rT7T80ERmRlhlhckJBOLbXSbYA24PBOQfC z4vnwwz4yHfnlv8fFW6K8VnSCXf03XM= X-Google-Smtp-Source: ABdhPJwdFHIazJzEsLv3oZlGObmzXJ8Jyt0fb0gYK38V+TngxpDoP651VD5XTPlW1Bav2NmOhlXtQw== X-Received: by 2002:adf:828b:: with SMTP id 11mr79985951wrc.58.1594532933439; Sat, 11 Jul 2020 22:48:53 -0700 (PDT) Received: from nol (eth-east-parth2-46-193-64-232.wb.wifirst.net. [46.193.64.232]) by smtp.gmail.com with ESMTPSA id z16sm17362398wrr.35.2020.07.11.22.48.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2020 22:48:52 -0700 (PDT) Date: Sun, 12 Jul 2020 07:48:50 +0200 From: Julien Rouhaud To: pgsql-hackers@lists.postgresql.org Subject: Avoid useless retrieval of defaults and check constraints in pg_dump -a Message-ID: <20200712054850.GA92357@nol> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="vkogqOf2sHV7VnPd" Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --vkogqOf2sHV7VnPd Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, Currently, getTableAttrs() always retrieves info about columns defaults and check constraints, while this will never be used if --data-only option if used. This seems like a waste of resources, so here's a patch to skip those parts when the DDL won't be generated. --vkogqOf2sHV7VnPd Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v1-pg_dump_data_only.diff" diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index e758b5c50a..e4ea604dfe 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -8590,7 +8590,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) /* * Get info about column defaults */ - if (hasdefaults) + if (!dopt->dataOnly && hasdefaults) { AttrDefInfo *attrdefs; int numDefaults; @@ -8677,7 +8677,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables) /* * Get info about table CHECK constraints */ - if (tbinfo->ncheck > 0) + if (!dopt->dataOnly && tbinfo->ncheck > 0) { ConstraintInfo *constrs; int numConstrs; --vkogqOf2sHV7VnPd--