Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7q8N-0005Ab-6N for pgsql-performance@arkaria.postgresql.org; Mon, 27 Jan 2014 17:38:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1W7q8M-0006oP-FO for pgsql-performance@arkaria.postgresql.org; Mon, 27 Jan 2014 17:38:06 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7q8J-0006k8-KV for pgsql-performance@postgresql.org; Mon, 27 Jan 2014 17:38:03 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1W7q8G-0006M9-9q for pgsql-performance@postgresql.org; Mon, 27 Jan 2014 17:38:02 +0000 Received: from compute4.internal (compute4.nyi.mail.srv.osa [10.202.2.44]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id 73786780 for ; Mon, 27 Jan 2014 12:37:58 -0500 (EST) Received: from web2 ([10.202.2.212]) by compute4.internal (MEProxy); Mon, 27 Jan 2014 12:37:58 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=iancu.ch; h= message-id:from:to:mime-version:content-transfer-encoding :content-type:in-reply-to:references:subject:date; s=mesmtp; bh= InaO0aw2euu8R3TZbnepFhALVHs=; b=gtw0sbl3Bo/kZQZ0vYzl1wtm+WLuamjP I5912DOMyDpMDTG83iFa8szrabM6Gwp3C4uDr3r2kys/pzxDX63WhhAYOwJXKsZQ BqvGuBgsmwi3qWcHQnfr6JJTfuWJ32H9jp4d76tLz+Pw+foS1Cued34o+SXV7tNU hS8Aeg3dmcE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:in-reply-to:references :subject:date; s=smtpout; bh=InaO0aw2euu8R3TZbnepFhALVHs=; b=Hur s4t4cd9+13BjcBMCq9O4Jy4wJpQPWru6aqKYrI5s9GD5KkfCOzdmgL65MWD8LF6g vSpsyUtUJhJYR+2OWsDzwk8hEcYhX7Meg7zcHg/b+7vQeAT4CSINVYOIkH4qV48T Akwj48dmZ/XN0kxyZQRItc8caeFK7etTszOP09V8= Received: by web2.nyi.mail.srv.osa (Postfix, from userid 99) id 2F4D1540101; Mon, 27 Jan 2014 12:37:58 -0500 (EST) Message-Id: <1390844278.5638.75903621.2E4ABB56@webmail.messagingengine.com> X-Sasl-Enc: Lh9gEKHLyeTnnn/TlBvP/ThnY3IEsDSQxuJQZnqvYRyj 1390844278 From: Stelian Iancu To: pgsql-performance@postgresql.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-aec78a11 In-Reply-To: <2631.1390835184@sss.pgh.pa.us> References: <1390833860.7369.75825537.0CAF7BA8@webmail.messagingengine.com> <2631.1390835184@sss.pgh.pa.us> Subject: Re: Slow query (wrong index used maybe) Date: Mon, 27 Jan 2014 09:37:58 -0800 X-Pg-Spam-Score: -2.7 (--) 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 Mon, Jan 27, 2014, at 7:06, Tom Lane wrote: > Stelian Iancu writes: > > I have Postrgres 9.3 running on a Linux machine with 32GB RAM. I have a > > fairly large database (some tables with approx. 1 mil. records) and I > > have the following query: > > [ 13-way join joined to a 3-way join ] > > Think you'll need to raise join_collapse_limit and from_collapse_limit > to get the best plan here. The planning time might hurt, though. > I did raise both to 40 and it works flawless (for now). I got the response time to less than a second. However I don't know what the implications are for the future. > TBH that schema looks designed for inefficiency; you'd be better off > rethinking the design rather than hoping the planner is smart enough > to save you from it. > Heh, I wish it was this easy. This whole thing is part of us moving away from Oracle to Postgres. We already have this huge DB with this schema in Oracle (which was successfully imported into Postgres, minus these performance issues we're seeing now) and I don't know how feasible it is to even start thinking about a redesign. But I appreciate your input regarding this. Maybe one of these days I will have success in convincing my boss to even start taking a look at the design of the DB (you know the saying "it works, don't fix it"). > 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 -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance