Re: Need to increase performance of a query

From: Anne Rosset <arosset(at)collab(dot)net>
To: Jesper Krogh <jesper(at)krogh(dot)cc>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Need to increase performance of a query
Date: 2010-06-10 18:36:08
Message-ID: 4C113098.5040105@collab.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Jesper Krogh wrote:
> On 2010-06-10 19:50, Anne Rosset wrote:
>> Any advice on how to make it run faster?
>
> What timing do you get if you run it with \t (timing on) and without
> explain analyze ?
>
> I would be surprised if you can get it much faster than what is is.. I
> may be that a
> significant portion is "planning cost" so if you run it a lot you
> might benefit from
> a prepared statement.
>
>
Hi Jesper,
Thanks your response:
psrdb=# \timing
Timing is on.
psrdb=# (SELECT
psrdb(# MAX(item_rank.rank) AS maxRank
psrdb(# FROM
psrdb(# item_rank item_rank
psrdb(# WHERE
psrdb(# item_rank.project_id='proj2783'
psrdb(# AND item_rank.pf_id IS NULL
psrdb(#
psrdb(# )
psrdb-# ORDER BY
psrdb-# maxRank DESC;
maxrank
-------------
20200000000
(1 row)

Time: 12.947 ms

It really seems to me that it should take less time.

Specially when I see the result with a different where clause like
this one:
psrdb=# SELECT
psrdb-# MAX(item_rank.rank) AS maxRank
psrdb-# FROM
psrdb-# item_rank item_rank
psrdb-# WHERE
psrdb-# item_rank.pf_id='plan1408'
psrdb-# ORDER BY
psrdb-# maxRank DESC;
maxrank
-------------
20504000000
(1 row)

Time: 2.582 ms

Thanks,
Anne

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Jochen Erwied 2010-06-10 19:22:11 Re: Need to increase performance of a query
Previous Message hubert depesz lubaczewski 2010-06-10 18:33:56 Re: Need to increase performance of a query