|
Changeset |
Optimize summary time stats query
The query for issues time stats is based on bug history, and history
queries are expensive when scanning a lot of issues.
The previous query retrieves all individual times for each issue, and
then processes all the rows to find the maximum, average, etc. This
processing, for a big number of issues, adds a considerable time to the
function execution.
With this change:
- Introduce a database api check to know if window functions (analytic)
are supported by current database.
- When window functions are availabe, perform a query that computes the
aggregated values by itself. The result is now only one row.
- When window functions are not available, perform the simple, non
aggregated query as before.
The time cost for the windowed query is very similar to the previous
version, but it improves:
- No postprocessing time.
- By returning one row, it can be effectively cached by the database,
and further reduce times in succesive page loads.
|