Skip to content

Commit

Permalink
Limit the number of generated rows in view_top_proxy_files
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKolarik committed Oct 16, 2024
1 parent 9e3a3b9 commit 5ce7110
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion migrations/shared/routines.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,23 @@ ${periods.map(period => topProxiesForPeriod(period)).join('\n')}
join proxy_file_hits on proxy_file.id = proxy_file_hits.proxyFileId
where date >= aDateFrom and date <= aDateTo
group by proxy_file.id
order by hits desc;
order by hits desc
limit 10000;
insert into view_top_proxy_files
(period, date, name, filename, hits, bandwidth)
select aPeriod, aDate,
(select name from proxy where id = proxyId) as name,
filename,
sum(hits) as hits,
sum(bandwidth) as bandwidth
from proxy_file
join proxy_file_hits on proxy_file.id = proxy_file_hits.proxyFileId
where date >= aDateFrom and date <= aDateTo
group by proxy_file.id
order by bandwidth desc
limit 10000
on duplicate key update name = name; # we already have the row; ignore
call logProcedureCallEnd();
commit;
Expand Down

0 comments on commit 5ce7110

Please sign in to comment.