Tuesday, 10 September 2013

Other way to write this query

Other way to write this query

I have 2 tables STAT1 and STAT2 with the same structure and column names.
I use STAT1 to load the latest CSV file, the rest of them get loaded to
STAT2. The database is only for statistics, the columns that matter here
are: function, value and username. I'm getting the average response time
for every function the user has used when there's a problem and comparing
it to the average response time for the week prior. here is the query:
select a.functions,
avg(a.value),
avg(b.value)
from STAT1 a,
STAT2 partition (p9) b
where a.functions = b.functions
and a.username = '<USERNAME>'
group by a.functions
order by a.functions desc;
The query works fine but takes a long time. Any other way to accomplish
the same result?
Any input would be great and thanks in advance.

No comments:

Post a Comment