Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UrbUO-0001wR-G5 for pgsql-performance@arkaria.postgresql.org; Tue, 25 Jun 2013 22:13:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1UrbUM-0004T4-Hk for pgsql-performance@arkaria.postgresql.org; Tue, 25 Jun 2013 22:13:26 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UrbUK-0004Sv-B3 for pgsql-performance@postgresql.org; Tue, 25 Jun 2013 22:13:24 +0000 Received: from nm37-vm0.bullet.mail.bf1.yahoo.com ([72.30.238.200]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1UrbUD-0006RC-4g for pgsql-performance@postgresql.org; Tue, 25 Jun 2013 22:13:23 +0000 Received: from [98.139.212.148] by nm37.bullet.mail.bf1.yahoo.com with NNFMP; 25 Jun 2013 22:13:15 -0000 Received: from [98.139.212.198] by tm5.bullet.mail.bf1.yahoo.com with NNFMP; 25 Jun 2013 22:13:15 -0000 Received: from [127.0.0.1] by omp1007.mail.bf1.yahoo.com with NNFMP; 25 Jun 2013 22:13:15 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 781616.33167.bm@omp1007.mail.bf1.yahoo.com Received: (qmail 34342 invoked by uid 60001); 25 Jun 2013 22:13:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ymail.com; s=s1024; t=1372198395; bh=ZqU2J5bm9Iamgj6qVXKM2HIOKZ2vHVVfvQ3pC2FLb0I=; 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=bag00eFTLPiFmvYUmqdazvGomYfaXms0uypnvpwCpDb4fvt4fs+gOTAtvFWo7x9ObTBxhTHTAP4kRUuM7n3hYTjNnyOdyI0iwTygm3/Tke3Ip1NpIFA31vktbXxD5vJiw9t1kglEyFZy8EfEZ7NFVBfCVMxPn57zFIiNp8UshsM= 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=AdPY8qVYCcFYfGSWFOcoWTGa9foL5gP082NHPmS60dDNSjsMmJATwvgZJWRO8+M1NL0inFKGoyh3b+DykbBH8HteEZGp2F6/+2lhOhmjGlpvF+28eQ5t4nFEi9X3fOtGzQNKjgMQBZG75Ig03rSVHKDw0ZHz5dnCM8UKF759dVI=; X-YMail-OSG: dkmk1kUVM1mdyFme9dt_jMMebEgwdPRXFI7_br2AHqdTg3o oQ1ad6gyFKIjUvXwiAYdnIkOSwQJVSAcwzK58tvhSWAFA_PKz23fykfFky8. Lv2dd8szFCmooje6s6_a4J0ewWsTGhwWvCQ2ZT8J3k0ERyP9c2HcYxCFMAYB Y8f9GGiGQICJL4aRrsFV4iVAPRPM0NXc73.hS9OPqqSwF2pXOJMqe9xVRYti pAr7N4mDosdkzAaC31_r0K.CTn8zBiqHn9ZuEh.VDiK_7Lw0c9Hw0_Rp4r.j A56LZht_C_qUPLhctzqtmEzCZj_BWeVXfxR7LWpI1_wdwdS6lZ1SPdJPjO_5 aXh3CcswZkbQXU7o7XdQnjUGkABpXDal7fdQh6hyqw.hn5SE2eElpmWJJQiE 6xZcr.osQDpAeml8Ri7o0xmIIqtblcwBSr199zAa9hiUkHbY_s22A09gel8l h8RzqKwWuIynI_WbZ9ogxZhZwnJcrJbrVlhrFl05MCUmVH2dTE_qY4JEeN5t 4v.r3y3fORzFJ7uYSIABMgdeGFjCibuiaxuHc.YUSno3nuhRzaiCP.PokJIX I.HseaQdLqnjLe8THSvZeRtOYESQ- Received: from [76.255.18.237] by web162904.mail.bf1.yahoo.com via HTTP; Tue, 25 Jun 2013 15:13:15 PDT X-Rocket-MIMEInfo: 002.001, QmVuIDxtaWRmaWVsZEBnbWFpbC5jb20.IHdyb3RlOgoKPiBpdCBzZWVtcyB0byBtZSB0aGF0IGFuIGVxdWFsaXR5IGpvaW4gYmV0d2VlbiB0d28gcmVsYXRpb25zIChjYWxsIHRoZW0gQSBhbmQgQikKPiB1c2luZyBjb2x1bW5zIGluIHJlbGF0aW9uIEIgd2l0aCBhIHVuaXF1ZSBjb25zdHJhaW50IHNob3VsZCB5aWVsZCByb3cgZXN0aW1hdGVzCj4gd2hpY2ggYXJlIGF0IG1vc3QgZXF1YWwgdG8gdGhlIHJvdyBlc3RpbWF0ZXMgZm9yIHJlbGF0aW9uIEEuwqAgbXkgcXVlc3Rpb25zIGFyZQo.Cj4gMSAtIGlzIHQBMAEBAQE- X-Mailer: YahooMailWebService/0.8.148.554 References: <7D0DD8B1-D23C-4BBC-9AB2-20D81F0B4BB8@gmail.com> <9A75BF4B-0458-43E3-803B-E25BB1984A39@gmail.com> <1372166429.65996.YahooMailNeo@web162901.mail.bf1.yahoo.com> Message-ID: <1372198395.32951.YahooMailNeo@web162904.mail.bf1.yahoo.com> Date: Tue, 25 Jun 2013 15:13:15 -0700 (PDT) From: Kevin Grittner Reply-To: Kevin Grittner Subject: Re: incorrect row estimates for primary key join To: Ben Cc: bricklen , "pgsql-performance@postgresql.org list" In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: 0.7 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org Ben wrote: > it seems to me that an equality join between two relations (call them A a= nd B) > using columns in relation B with a unique constraint should yield row est= imates > which are at most equal to the row estimates for relation A.=A0 my questi= ons are > > 1 - is this correct? > > 2 - does the postgresql planner implement this when generating row estima= tes? That seems intuitive, but some of the estimates need to be made before all such information is available.=A0 Maybe we can do something about that some day.... > while i do have a performance > issue (i'd like for it to select > the index scan) which might be solved by better configuration, > that at the moment is a secondary question -- right now i'm > interested in why the row estimates are off. Maybe someone else will jump in here with more details than I can provide (at least without hours digging in the source code). > On Jun 25, 2013, at 6:20 AM, Kevin Grittner wrote: >> Ben wrote: >> >>> PostgreSQL 9.1.1 on x86_64-suse-linux-gnu, compiled by gcc (SUSE Linux) >>> 4.6.2, 64-bit >> >> Consider applying the latest bug fixes for 9.1 -- which would leave >> you showing 9.1.9. > > i will bring it up with our ops people.=A0 do you have any particular fix= es in > mind, or is this a (very sensible) blanket suggestion? I do recommend staying up-to-date in general (subject to roll-out procedures),=A0 We try very hard not to change any behavior that isn't a clear bug from one minor release to the next, precisely so that people can apply these critical bug fixes with confidence that things won't break.=A0 There is a fix for a pretty significant security vulnerability you are currently missing, which would be my top concern; but it wouldn't be surprising if there were a planner bug in 9.1.1 which is fixed in 9.1.9. >> Do you get a different plan if you set cpu_tuple_cost =3D 0.03?=A0 How >> about 0.05?=A0 You can set this just for a single connection and run >> explain on the query to do a quick check. > > setting cpu_tuple_cost to 0.03 or 0.05 has no effect on the choice of pla= n or > the row estimates for the un-limited query or the limited query. That wouldn't affect row estimates, but it would tend to encourage index usage, because it would increase the estimated cost of reading each row. -- Kevin Grittner EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company --=20 Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance