Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UGWlw-0007fr-Em for pgsql-performance@arkaria.postgresql.org; Fri, 15 Mar 2013 15:42:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UGWlv-0006Kf-Va for pgsql-performance@arkaria.postgresql.org; Fri, 15 Mar 2013 15:42:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UGWlv-0006Ka-9B for pgsql-performance@postgresql.org; Fri, 15 Mar 2013 15:42:19 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UGWls-0005a6-TT for pgsql-performance@postgresql.org; Fri, 15 Mar 2013 15:42:18 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id r2FFgFJh006305; Fri, 15 Mar 2013 11:42:15 -0400 (EDT) From: Tom Lane To: Ao Jianwang cc: pgsql-performance@postgresql.org Subject: Re: Join the master table with other table is very slow (partitioning) In-reply-to: References: Comments: In-reply-to Ao Jianwang message dated "Fri, 15 Mar 2013 23:02:28 +0800" Date: Fri, 15 Mar 2013 11:42:14 -0400 Message-ID: <6303.1363362134@sss.pgh.pa.us> X-Pg-Spam-Score: -4.3 (----) 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 Ao Jianwang writes: > I found if we join the master table with other small table, then the > running time is slow. While, if we join each child table with the small > table, then it's very fast. Any comments and suggestions are greatly > appreciated. https://wiki.postgresql.org/wiki/Slow_Query_Questions You haven't shown us table schemas, particularly the index definitions. It looks to me like the partition child tables probably don't have indexes that are well adapted to this query. Equality constraints should be on leading columns of the index, but the only index I see evidence of in your plans has the date column first. Probably the planner is considering an inner-indexscan plan and rejecting it as being more expensive than this one, because it would have to scan too much of the index. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance