Re: help optimizing query

From: "Adam Rich" <adam(dot)r(at)sbcglobal(dot)net>
To: <rihad(at)mail(dot)ru>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: help optimizing query
Date: 2008-02-10 02:04:57
Message-ID: 00af01c86b89$5607ea30$0217be90$@r@sbcglobal.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> It seems to do the job, but how good is it in the long run? Any way I
> could tweak it?

I think this form will work the best:

SELECT u.login, MAX(s.stop_time) AS last_use_time
FROM users u, stats s
WHERE u.id=s.user_id
AND u.status='3' AND u.next_plan_id IS NULL
GROUP BY u.login
HAVING MAX(s.stop_time) < (now() - interval '1 month')
ORDER BY last_use_time;

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-02-10 02:45:43 Re: Where is the system-wide psqlrc on RHEL4?
Previous Message Dean Gibson (DB Administrator) 2008-02-10 02:01:19 Where is the system-wide psqlrc on RHEL4?