Re: Slow query - Mailing list pgsql-performance

From Bikram Kesari Naik
Subject Re: Slow query
Date
Msg-id B2F5FFCC2D252A4DABEC0CB0C4E8100405878B36@JETWINSRVEC01.onmobile.com
Whole thread Raw
In response to Re: Slow query  (David Johnston <polobo@yahoo.com>)
Responses Re: Slow query
List pgsql-performance
Hi David,

We have indexes on all the columns which are used in the where clause and these tables are linked by foreign key
constraint.


Thanks,
Bikram

-----Original Message-----
From: pgsql-performance-owner@postgresql.org [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of David
Johnston
Sent: Friday, March 07, 2014 11:53 AM
To: pgsql-performance@postgresql.org
Subject: Re: [PERFORM] Slow query

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
indexdefinitions 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
withindexes 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

________________________________

DISCLAIMER: The information in this message is confidential and may be legally privileged. It is intended solely for
theaddressee. Access to this message by anyone else is unauthorized. If you are not the intended recipient, any
disclosure,copying, or distribution of the message, or any action or omission taken by you in reliance on it, is
prohibitedand may be unlawful. Please immediately contact the sender if you have received this message in error.
Further,this e-mail may contain viruses and all reasonable precaution to minimize the risk arising there from is taken
byOnMobile. OnMobile is not liable for any damage sustained by you as a result of any virus in this e-mail. All
applicablevirus checks should be carried out by you before opening this e-mail or any attachment thereto. 
Thank you - OnMobile Global Limited.


pgsql-performance by date:

Previous
From: David Johnston
Date:
Subject: Re: Slow query
Next
From: David Johnston
Date:
Subject: Re: Slow query