Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id CD5FB6324F3 for ; Tue, 20 Jan 2009 17:04:18 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 09038-07 for ; Tue, 20 Jan 2009 17:04:15 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail1.sea5.speakeasy.net (mail1.sea5.speakeasy.net [69.17.117.3]) by mail.postgresql.org (Postfix) with ESMTP id 4119B632349 for ; Tue, 20 Jan 2009 17:04:15 -0400 (AST) Received: (qmail 31960 invoked from network); 20 Jan 2009 21:04:08 -0000 Received: from digital-subscriber-line.bepress.com (HELO xena.bepress.com) ([216.27.183.41]) (envelope-sender ) by mail1.sea5.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 20 Jan 2009 21:04:08 -0000 Received: from [192.168.1.146] (unknown [192.168.1.146]) by xena.bepress.com (Postfix) with ESMTP id B6BAF73587 for ; Tue, 20 Jan 2009 13:04:07 -0800 (PST) Message-ID: <49763C47.7070400@obviously.com> Date: Tue, 20 Jan 2009 13:04:07 -0800 From: Bryce Nesbitt User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.17) Gecko/20080829 SeaMonkey/1.1.12 (Ubuntu-1.1.12+nobinonly-0ubuntu0.8.04.1) MIME-Version: 1.0 CC: Pgsql Hackers Subject: New pg_dump patch, --no-stats flag, disables sending to statistics collector References: <483FD205.4090904@sigaev.ru> <486BC501.6060605@sigaev.ru> <27880.1215810535@sss.pgh.pa.us> <487A6E0C.3090600@sigaev.ru> <8993.1216843701@sss.pgh.pa.us> <4888A594.6010102@sigaev.ru> <490B07BA.6030109@sigaev.ru> <492F04D9.5070404@enterprisedb.com> <4942A137.3000502@sigaev.ru> <1229910966.2285.76.camel@jdavis> <49708008.8070109@sigaev.ru> <1232348905.7281.114.camel@jdavis> <4974B002.3040202@sigaev.ru> <1232474489.23316.8.camel@jdavis> In-Reply-To: <1232474489.23316.8.camel@jdavis> Content-Type: multipart/mixed; boundary="------------040903000005000609000103" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.581 tagged_above=0 required=5 tests=MISSING_HEADERS=1.581 X-Spam-Level: * X-Archive-Number: 200901/1475 X-Sequence-Number: 132119 This is a multi-part message in MIME format. --------------040903000005000609000103 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit This patch adds another flag to pg_dump, this time to disable statistics collection. This is useful if your don't want pg_dump activity to show (or clutter) your normal statistics. This may be appropriate for an organization that regularly dumps a database for backup purposes, but wants to analyze only the application's database use. This is patched against CVS HEAD from today, though the code is quite version independent. This patch is unsolicited, and as far as I know has not been discussed on the list prior to now. Comments? --------------040903000005000609000103 Content-Type: text/x-diff; name="pg_dump.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pg_dump.patch" Index: pg_dump.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v retrieving revision 1.514 diff -c -2 -r1.514 pg_dump.c *** pg_dump.c 18 Jan 2009 20:44:45 -0000 1.514 --- pg_dump.c 20 Jan 2009 20:47:25 -0000 *************** *** 236,239 **** --- 236,240 ---- static int outputNoTablespaces = 0; static int use_setsessauth = 0; + static int noStatsCollection = 0; static struct option long_options[] = { *************** *** 278,281 **** --- 279,283 ---- {"role", required_argument, NULL, 3}, {"use-set-session-authorization", no_argument, &use_setsessauth, 1}, + {"no-stats", no_argument, &noStatsCollection, 1}, {NULL, 0, NULL, 0} *************** *** 430,433 **** --- 432,437 ---- else if (strcmp(optarg, "no-tablespaces") == 0) outputNoTablespaces = 1; + else if (strcmp(optarg, "no-stats") == 0) + noStatsCollection = 1; else if (strcmp(optarg, "use-set-session-authorization") == 0) use_setsessauth = 1; *************** *** 613,616 **** --- 617,629 ---- do_sql_command(g_conn, "SET statement_timeout = 0"); + /* + * Disable collection of statistics. pg_dump's activity may be very different + * from what you are trying to analyze in the stats tables. + */ + if( noStatsCollection ) { + do_sql_command(g_conn, "SET stats_block_level = false"); + do_sql_command(g_conn, "SET stats_row_level = false"); + } + /* * Start serializable transaction to dump consistent data. *************** *** 833,836 **** --- 846,850 ---- printf(_(" -U, --username=NAME connect as specified database user\n")); printf(_(" -W, --password force password prompt (should happen automatically)\n")); + printf(_(" --no-stats disable statistics collection (superuser only)\n")); printf(_("\nIf no database name is supplied, then the PGDATABASE environment\n" --------------040903000005000609000103--