Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WLoBe-00012J-7d for pgsql-performance@arkaria.postgresql.org; Fri, 07 Mar 2014 06:23:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WLoBd-0000nP-Nx for pgsql-performance@arkaria.postgresql.org; Fri, 07 Mar 2014 06:23:13 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WLoBc-0000nI-HX for pgsql-performance@postgresql.org; Fri, 07 Mar 2014 06:23:12 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WLoBZ-0002KI-Vy for pgsql-performance@postgresql.org; Fri, 07 Mar 2014 06:23:11 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1WLoBY-0000Xt-JY for pgsql-performance@postgresql.org; Thu, 06 Mar 2014 22:23:08 -0800 Date: Thu, 6 Mar 2014 22:23:08 -0800 (PST) From: David Johnston To: pgsql-performance@postgresql.org Message-ID: <1394173388580-5795079.post@n5.nabble.com> In-Reply-To: References: Subject: Re: Slow query MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 4.5 (++++) 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 Bikram Kesari Naik wrote > Hi, > > I have a view which joins multiple tables to give me a result. It takes > more than a minute to give me the result on psql prompt when I select all > the data from that view. > The single CPU which is used to run this query is utilized 100%.Even if I > fire a count(*) it takes 10 Sec. I wanted to know if there is anything we > can do to speedup this query below 1 sec. In all likelihood you need to index your foreign keys, and possibly other fields, but as you haven't provided table and index definitions it is hard to say for sure. Idepeing on how many rows are hidden I'm not sure an unqualified query on this view can run in 1/60th the time even with indexes present - the sequential scans are efficient if the proportion of the tables being returned is high. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Slow-query-tp5795077p5795079.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