Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7raH-0000yd-9j for pgsql-performance@arkaria.postgresql.org; Mon, 27 Jan 2014 19:11:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W7raG-0007UT-N6 for pgsql-performance@arkaria.postgresql.org; Mon, 27 Jan 2014 19:11:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7raF-0007UN-TU for pgsql-performance@postgresql.org; Mon, 27 Jan 2014 19:10:59 +0000 Received: from sam.nabble.com ([216.139.236.26]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7ra8-0001cX-NG for pgsql-performance@postgresql.org; Mon, 27 Jan 2014 19:10:59 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1W7ra5-00066n-W0 for pgsql-performance@postgresql.org; Mon, 27 Jan 2014 11:10:49 -0800 Date: Mon, 27 Jan 2014 11:10:49 -0800 (PST) From: bobJobS To: pgsql-performance@postgresql.org Message-ID: <1390849849986-5789045.post@n5.nabble.com> In-Reply-To: <1390844278.5638.75903621.2E4ABB56@webmail.messagingengine.com> References: <1390833860.7369.75825537.0CAF7BA8@webmail.messagingengine.com> <2631.1390835184@sss.pgh.pa.us> <1390844278.5638.75903621.2E4ABB56@webmail.messagingengine.com> Subject: Re: Slow query (wrong index used maybe) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 1.8 (+) 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 My developers have had the same issue. Postgres 9.2.3 on Linux 5.6. The query planner estimates (for 27 table join SQL) that using the nestloop is faster, when in fact it is not. A hashjoin returns results faster. We've set enable_nestloop = false and have gotten good results. The problem is, nestoop would be faster for other types of queries. Maybe ones with fewer joins. Recently we made a change that forced our multi join queires to slow down. We now build temp views for each user session. To speed these queries up, we up'd geqo_effort = 10. This has also given us good results; but again, we don't know if there will be another impact down the road. Same issue here with redesign. There is some simple denormalization we could do that would minimize our joins. Instead if link tables, we would utilize hstore, json or array columns types. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Slow-query-wrong-index-used-maybe-tp5788979p5789045.html Sent from the PostgreSQL - performance mailing list archive at Nabble.com. -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance