Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Ven6w-0004VI-VN for pgsql-performance@arkaria.postgresql.org; Fri, 08 Nov 2013 14:32:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Ven6w-0002xG-EB for pgsql-performance@arkaria.postgresql.org; Fri, 08 Nov 2013 14:32:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Ven6u-0002ve-OH for pgsql-performance@postgresql.org; Fri, 08 Nov 2013 14:32:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Ven6o-0002PA-7P for pgsql-performance@postgresql.org; Fri, 08 Nov 2013 14:32:32 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id rA8EVgYh027471; Fri, 8 Nov 2013 09:31:42 -0500 From: Tom Lane To: Jan Walter cc: postgres performance list Subject: Re: Size of IN list affects query plan In-reply-to: <527CEF87.6080008@commontongue.com> References: <527CEF87.6080008@commontongue.com> Comments: In-reply-to Jan Walter message dated "Fri, 08 Nov 2013 15:04:55 +0100" Date: Fri, 08 Nov 2013 09:31:42 -0500 Message-ID: <27470.1383921102@sss.pgh.pa.us> 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 Jan Walter writes: > I would like to know, how does the size of the IN list affect query planner. AFAICT, the reason the second plan is slow is the large number of checks of the IN list. The planner does account for the cost of that, but it's drastically underestimating that cost relative to the cost of I/O for the heap and index accesses. I suppose that your test case is fully cached in memory, which helps make the CPU costs more important than I/O costs. If you think this is representative of your real workload, then you need to decrease random_page_cost (and maybe seq_page_cost too) to make the cost estimates correspond better to that reality. 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