Re: Slow query

From: Bikram Kesari Naik <bikram(dot)naik(at)onmobile(dot)com>
To: David Johnston <polobo(at)yahoo(dot)com>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Slow query
Date: 2014-03-07 06:43:23
Message-ID: B2F5FFCC2D252A4DABEC0CB0C4E8100405878B36@JETWINSRVEC01.onmobile.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)postgresql(dot)org [mailto:pgsql-performance-owner(at)postgresql(dot)org] On Behalf Of David Johnston
Sent: Friday, March 07, 2014 11:53 AM
To: pgsql-performance(at)postgresql(dot)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 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(at)postgresql(dot)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 the addressee. 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 prohibited and 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 by OnMobile. OnMobile is not liable for any damage sustained by you as a result of any virus in this e-mail. All applicable virus checks should be carried out by you before opening this e-mail or any attachment thereto.
Thank you - OnMobile Global Limited.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message David Johnston 2014-03-07 07:18:29 Re: Slow query
Previous Message David Johnston 2014-03-07 06:23:08 Re: Slow query