Search Postgresql Archives

Re: help optimizing query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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;



---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux