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

--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

Reply via email to