[GENERAL] help optimizing query

2008-03-22 Thread George Nychis
Hi all, I'm looking for helping optimizing a query. It currently requires two passes on the data per query, when I'd like to try and write it to only require a single pass. Here's the high level, it's parsing flow level network traffic and it's interested in 4 fields: src_ip, dst_ip, src_p

Re: [GENERAL] help optimizing query

2008-02-09 Thread Scott Marlowe
On Feb 9, 2008 8:04 PM, Adam Rich <[EMAIL PROTECTED]> wrote: > > 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_

Re: [GENERAL] help optimizing query

2008-02-09 Thread Adam Rich
> 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.

[GENERAL] help optimizing query

2008-02-09 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