Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tjbxg-00085M-2J for pgsql-performance@arkaria.postgresql.org; Fri, 14 Dec 2012 20:34:24 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Tjbxe-0006c1-RP for pgsql-performance@arkaria.postgresql.org; Fri, 14 Dec 2012 20:34:22 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TjbxO-0006Ot-Uo for pgsql-performance@postgresql.org; Fri, 14 Dec 2012 20:34:07 +0000 Received: from mailout-us.gmx.com ([74.208.5.67]) by makus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TjbxN-0001R3-QZ for pgsql-performance@postgresql.org; Fri, 14 Dec 2012 20:34:06 +0000 Received: (qmail 21094 invoked by uid 0); 14 Dec 2012 20:34:05 -0000 Received: from 76.255.19.161 by rms-us004 with HTTP Cc: "AI Rumman" ,"Evgeny Shishkin" , "Andrew Dunstan" , "postgres performance list" Content-Type: text/plain; charset="utf-8" Date: Fri, 14 Dec 2012 15:34:03 -0500 From: "Kevin Grittner" Message-ID: <20121214203403.80070@gmx.com> MIME-Version: 1.0 Subject: Re: Why does the number of rows are different in actual and estimated. To: "Claudio Freire" ,"Tom Lane" X-Authenticated: #138763884 X-Flags: 0001 X-Mailer: GMX.com Web Mailer x-registered: 0 Content-Transfer-Encoding: 8bit X-GMX-UID: bOi5cCN+3zOlOQ09Lnwhokh+IGRvb8Do X-Pg-Spam-Score: -1.9 (-) 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 Claudio Freire wrote: > Selectivity is decided based on the number of distinct values on > both sides, and the table's name "entity" makes me think it's a > table that is reused for several things. That could be a problem, > since that inflates distinct values, feeding misinformation to > the planner. > > Rather than a generic "entity" table, perhaps it would be best to > separate them different entities into different tables. I missed that; good catch. Good advice. Don't try to build a "database within a database" by having one table for different types of data, with a code to sort them out. EAV is a seriously bad approach for every situation where I've seen someone try to use it. I was about to say it's like trying to drive a nail with a pipe wrench, then realized it's more like putting a bunch of hammers in a bag and swinging the bag at the nail. -Kevin -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance