From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Sebastian Ritter <ritter(dot)sebastian(at)gmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Query optimizing |
Date: | 2008-11-10 11:05:27 |
Message-ID: | 49181577.4090200@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Sebastian Ritter wrote:
> A lot of the reports our technical officers submit to us include a listing
> of all actioned issues for a given day along with the last modified followup
> of each said issue. With the number of rows in our database increasing at a
> high rate, these queries are starting to run too slowly.
> We have identified that the slowness in our queries is trying to return the
> lastest followup for each actioned issue that day. Without further ado here
> are two variations I have tried within the system (neither of which are
> making the cut):
>
> V1 (correlated subquery - Very bad performance)
>
> (SELECT
> fu.*
> FROM
> manage_followup fu,
> manage_issue i
> WHERE
> i.id = fu.n_issue
> AND
> fu.id = (SELECT
> id
> FROM
> manage_followup
> WHERE
> n_issue = i.id
> ORDER BY
> dt_modified DESC
> LIMIT 1)) AS latestfu,
>
Do you have an index on (id,dt_modified) for manage_followup? Can you
provide an EXPLAIN ANALYSE for this?
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | Helio Campos Mello de Andrade | 2008-11-10 11:28:37 | Re: Seq scan on join, not on subselect? analyze this |
Previous Message | Sebastian Ritter | 2008-11-10 10:43:14 | Query optimizing |