Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U2rgd-0008Cz-0g for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Feb 2013 23:12:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U2rgc-0006ui-HD for pgsql-bugs@arkaria.postgresql.org; Tue, 05 Feb 2013 23:12:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U2rgb-0006ud-RT for pgsql-bugs@postgresql.org; Tue, 05 Feb 2013 23:12:21 +0000 Received: from nm36-vm0.bullet.mail.bf1.yahoo.com ([72.30.238.136]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U2rgX-0007bv-CN for pgsql-bugs@postgresql.org; Tue, 05 Feb 2013 23:12:21 +0000 Received: from [98.139.215.143] by nm36.bullet.mail.bf1.yahoo.com with NNFMP; 05 Feb 2013 23:12:15 -0000 Received: from [98.139.212.211] by tm14.bullet.mail.bf1.yahoo.com with NNFMP; 05 Feb 2013 23:12:15 -0000 Received: from [127.0.0.1] by omp1020.mail.bf1.yahoo.com with NNFMP; 05 Feb 2013 23:12:15 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 429193.78279.bm@omp1020.mail.bf1.yahoo.com Received: (qmail 52333 invoked by uid 60001); 5 Feb 2013 23:12:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s1024; t=1360105935; bh=4ex0BPZ2RbQb+cm9XiCdANc+bpDGa5ys3lWsF1KME4I=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=5s9g1Dwhz9AXa2wJQ8zI3ClxvbfLdhmvJHvbciltsM/BLrEoweHaK2RyCVEMDQYQmgrrBt/aj8ga0fb6H138QBg2IeapUy3hlLojpeuhrSOthAnEH0DS8Gzk8q2DBl0xcEE5bMZS11pEumkaA7GD9bZgI3hLzC5Sipuf1lA3Pxo= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=ymail.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=VgjW6sB3d9erFt9m0LUvzmS4cLSuKeifwf3rbZ72WD2b+qmW1rZAib53txL8cKJySMr03PLaBrcP50oNZT70stcZzM4hPQL4ZDaIpIfoDqqJb+8/faQdjjclznjCol9flVnZmkZXrraIVbCi5NrRL6N7p7gPwho1dou5LrrV9g8=; X-YMail-OSG: t0T34O8VM1lbe1Bhe2FsAVe5NZW1sezpl9pDuYhGzpLUTEN Xn4iLO35Naaz.Rj0ZmOdCGAZryD1ZjUS_fa.o__q8lB8Y_jViCKL_zlOX.EF d54B5VCkTBkRGg_fYQ6BdEfJIURizTepgZigM8_83FdLSE1KRD.7h72lVECR FUrGiASxBMYuio2VrNT9y.c2SkuEjHF5zo94nXyKgKYvnTJIAdSWodshL6zm Ry6Ndqxuau1gRAhdJjcYMZlKI7yozgQUeuv8vR3C6qL.xo1ymSQKB8pqGpox MzmnBoqVC_fkD2K6YUmhXyfh0oZnaHFbRFEEQUpRQrmDHJ2SP8JvDZ61IkIF Oxm5QC90itFeTLEjZ1Jx6rMY6bxD4tdy59Hf9EbCrf_LrFL84GV7TKjCUZBr .O7i2LOc9Ejfj1FBsY_O3ijF7p1lu0EZNmlQamWuVdqYYzT9Jqv.tpjlZ8aX 6TYeKYTE98RGD9BEm7b0BEG3_0iBn Received: from [76.255.19.161] by web162904.mail.bf1.yahoo.com via HTTP; Tue, 05 Feb 2013 15:12:15 PST X-Rocket-MIMEInfo: 001.001, SmFtZXMgUiBTa2FnZ3MgPGphbWVzLnIuc2thZ2dzQHNlYWdhdGUuY29tPiB3cm90ZToKCj4gQWdyZWVkLCB3ZSBzaG91bGRuJ3QgaGF2ZSBzbyBtYW55IGRlYWQgcm93cy7CoCBPdXIgYXV0b3ZhY3V1bSBpcwo.IHNldCBvbiBidXQgaGFzIGRlZmF1bHQgcGFyYW1ldGVycy7CoMKgIFdlIGFyZSBjbHVzdGVyaW5nIHRvZGF5LiAKPiBUaGlzLCBvZiBjb3Vyc2UsIG1lYW5zIGRvd250aW1lIGFuZCBpbmNvbnZlbmllbmNlIHRvIHRoZSB1c2Vycy4KClJpZ2h0LCB3aGljaCBpcyB3aHkgaXQncyBpbXBvcnRhbnQgdG8BMAEBAQE- X-Mailer: YahooMailWebService/0.8.132.503 References: <1360101646.24672.YahooMailNeo@web162901.mail.bf1.yahoo.com> Message-ID: <1360105935.25882.YahooMailNeo@web162904.mail.bf1.yahoo.com> Date: Tue, 5 Feb 2013 15:12:15 -0800 (PST) From: Kevin Grittner Reply-To: Kevin Grittner Subject: Re: BUG #7853: Incorrect statistics in table with many dead rows. To: James R Skaggs Cc: "jimbob@seagate.com" , "pgsql-bugs@postgresql.org" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org James R Skaggs wrote: > Agreed, we shouldn't have so many dead rows.=A0 Our autovacuum is > set on but has default parameters.=A0=A0 We are clustering today.=20 > This, of course, means downtime and inconvenience to the users. Right, which is why it's important to figure out why the bloat happened.=A0 Sometimes it is unavoidable, like when you delete 90% of the rows in your table or a long-lived "idle in transaction" connection prevents autovacuum from being able to do its work normally.=A0 To prevent further downtime it is important to figure out what happened and make appropriate changes to your monitoring or vacuuming. > Here is the troublesome query: > >> select=20 >>=A0=A0=A0 sum(case when t1.cdlc < 0 then 0 else t1.cdlc end) as code_line= _cnt,=20 >>=A0=A0=A0 sum(case when t1.cmlc < 0 then 0 else t1.cmlc end) as comment_l= ine_cnt,=20 >>=A0=A0=A0 sum(case when t1.bllc < 0 then 0 else t1.bllc end) as blank_lin= e_cnt=20 >>=A0 from=20 >>=A0=A0=A0 ( select=20 >>=A0=A0=A0=A0=A0=A0=A0 max(sf.current_code_line_count) as cdlc,=20 >>=A0=A0=A0=A0=A0=A0=A0 max(sf.current_comment_line_count) as cmlc, >>=A0=A0=A0=A0=A0=A0=A0 max(sf.current_blank_line_count) as bllc=20 >>=A0=A0=A0=A0=A0 from=20 >>=A0=A0=A0=A0=A0=A0=A0 stream_file sf=20 >>=A0=A0=A0=A0=A0 group by sf.file_path_id, sf.current_source_md5=20 >>=A0=A0=A0 ) as t1; Well, I don't see that the planner has a lot of choice there besides whether to use a sort or a hash to do the inner aggregation.=A0 Are you saying that prior to the bloat it used a hash aggregation, and that was faster?=A0 And that you feel that it should be using that even with the bloat?=A0 That the dead rows seem to be getting included in the statistics, driving to the slower plan, and you feel they should be omitted? Note that I'm not aruing one way or another on these points at the moment; I'm just trying to understand your point clearly. -Kevin --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs