Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X0CTH-0001FE-Iv for pgsql-performance@arkaria.postgresql.org; Thu, 26 Jun 2014 16:24:23 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X0CTF-0008F6-PM for pgsql-performance@arkaria.postgresql.org; Thu, 26 Jun 2014 16:24:21 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X0CT1-0007vK-U9 for pgsql-performance@postgresql.org; Thu, 26 Jun 2014 16:24:08 +0000 Received: from smtp.optionshouse.com ([38.98.137.6] helo=smtp.peak6.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X0CSv-00019t-2D for pgsql-performance@postgresql.org; Thu, 26 Jun 2014 16:24:03 +0000 X-AuditID: 0a64cb20-f79426d000005a0a-d9-53ac491f2139 Message-ID: <53AC491A.8090207@optionshouse.com> Date: Thu, 26 Jun 2014 11:23:54 -0500 From: Shaun Thomas User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Claudio Freire , AJ Weber CC: postgres performance list Subject: Re: how to improve perf of 131MM row table? References: <53AB2CB1.8080201@comcast.net> <53AB35CC.10202@optionshouse.com> <1801a5d4-c3f1-4c0c-9c2c-ffb9d7f723a3@email.android.com> <53AB4551.4070207@optionshouse.com> <53AC1F6E.4000700@comcast.net> <53AC3E8D.8040106@comcast.net> <53AC40CB.9020006@comcast.net> In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed content-transfer-encoding: 7bit X-Originating-IP: [10.10.220.56] X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGIsWRmVeSWpSXmKPExsXClcIrpivvuSbY4P98E4u76++xWzz51cRq cX3mOWYHZo/Jj+cweuycdZfd48K+aewBzFENjDaJeXn5JYklqQopqcXJtkr+BSWZ+XnFHvml xakKLpnFyTmJmbmpRUoKmSm2SsZKCgU5icmpual5JbZKiQUFqXkpSnZcChjABqgsM08hNS85 PyUzL91WyTPYX9fCwtRS11DJLh4ZJHSyZOz/MJu9YB5bxdSzYQ2MDaxdjJwcEgImEvtur2aC sMUkLtxbzwZi8wroS3R07gGzWQRUJZ7snsoIYrMJ6EpM6l8BFhcVCJN4POccI0S9oMTJmU9Y QGwRAS+JWxPXAs3k4GAWcJB4vTIJJCwsYCcx5+ZBoBIuDiGBCcwSS76uYgdJcAoESuzZ+Aqs l1nAQmLxm4PsELa8xPa3c5hBbCGgG1Y0T2QDmSkhoAB0Z+oERoFZSDbPQtI9C0n3AkbmVYzi xWWJyRmZpgXFuSUFRnoFqYnZZnp5qSWbGMGReVphB+P3TqtDjAIcjEo8vAWma4KFWBPLiitz DzFKcDArifB+sAMK8aYkVlalFuXHF5XmpBYfYvQBBs1EZinR5Hxg0sgriTc0NjUwtTQ1NDU3 NTTCIawkznukJS5YSCAdmBayU1MLUotgxjFxcEo1MJpM/Zu0YsHMln1WLXa7NXWmr2LtX7Zt c6SCnNyUzPsrin97bI/esNxqU8Yit9uGy7NvLvSen2Gso1N6+Pum8O1zJdrX5mu2vNXz9vS8 mLe3q+ynj7pry++nJ2YkfAuxvVz5Vo9Px5KhRKiDgeXuhN65D/36f29wijiS7KxQ96CxSk0q VSb1hxJLcUaioRZzUXEiAHqUCJv5AgAA 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 On 06/26/2014 11:19 AM, Claudio Freire wrote: > Try changing node_id in (...) into node.id in (...) Wow. How did we not see that earlier? That's probably the issue. If you look at the estimates of his query: Bitmap Heap Scan on alf_node_properties prop (cost=1253.19..189491.87 rows=52790 width=179) (actual time=0.571..1.349 rows=1071 loops=1) The planner is off by an order of magnitude, and since the matches are against node_id instead of node.id, it thinks it would have to index seek on the alf_node table for over 50k rows. I could easily see it opting for a sequence scan in that case, depending on how high random_page_cost is. -- Shaun Thomas OptionsHouse, LLC | 141 W. Jackson Blvd. | Suite 800 | Chicago IL, 60604 312-676-8870 sthomas@optionshouse.com ______________________________________________ See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance