elsenorjose
Technical User
Hello everyone...
I'm trying to create a view that feeds a reporting application (Crystal Reports) using the following query:
select
market,
station_id,
cprog,
count(distinct c_ip) as 'users',
date_time,
count(track) as 'sessions',
sum(bytes)/1000000000 as 'gbytes',
sum(x_duration) as 'xduration'
from live_play_table
group by market, station_id, cprog, c_ip
The reason I want to use a view is that when Crystal accesses just a base table, it retrieves all rows it thinks it needs (in this case 15-20 million rows) to perform its calculations. By creating a view that summarizes the data, I restrict the number of records returned down to the order of several thousand vs. several million.
The problem is that by including the distinct count of IPs (c_ip), the performance of this query is abysmal. It takes hours to retrieve the data. This is true in Query Browser as well as in Crystal so I'm sure it's a DB side issue.
Is there any other way to include the distinct count of IP addresses in the view while improving the performance of the query? If there is no c_ip group in the query, I retrieve just a few thousand rows and the query executes very quickly. If I have the c_ip group in there, I retrieve a few million rows...still fewer than Crystal retrieves from a base table but it results in a very slow execution.
I'm trying to create a view that feeds a reporting application (Crystal Reports) using the following query:
select
market,
station_id,
cprog,
count(distinct c_ip) as 'users',
date_time,
count(track) as 'sessions',
sum(bytes)/1000000000 as 'gbytes',
sum(x_duration) as 'xduration'
from live_play_table
group by market, station_id, cprog, c_ip
The reason I want to use a view is that when Crystal accesses just a base table, it retrieves all rows it thinks it needs (in this case 15-20 million rows) to perform its calculations. By creating a view that summarizes the data, I restrict the number of records returned down to the order of several thousand vs. several million.
The problem is that by including the distinct count of IPs (c_ip), the performance of this query is abysmal. It takes hours to retrieve the data. This is true in Query Browser as well as in Crystal so I'm sure it's a DB side issue.
Is there any other way to include the distinct count of IP addresses in the view while improving the performance of the query? If there is no c_ip group in the query, I retrieve just a few thousand rows and the query executes very quickly. If I have the c_ip group in there, I retrieve a few million rows...still fewer than Crystal retrieves from a base table but it results in a very slow execution.