[GENERAL] need help optimizing query

2008-02-02 Thread rihad
Hi all, The situation: there are users in one table, and their access statistics in the other. Now I want to find users whose last access time was more than one month ago. As I've only had to write quite simple queries involving no sub-selects so far, I'd like to ask your opinion if this one

Re: [GENERAL] need help optimizing query

2008-02-02 Thread Olexandr Melnyk
Here's one without a subquery, so may be master: select u.login, s.stop_time from users as a inner join stats as s on s.user_id = u.user_id where status = '3' and next_plan_id is null and stop_time now() - interval '1 month' group by u.user_id, u.login, s.stop_time