Compare commits

..

6 Commits
5.3.0 ... 5.3.1

Author SHA1 Message Date
Rafa de la Torre
97972ac73f Update NEWS.md with v5.3.1 2018-02-13 09:05:06 +01:00
Rafa de la Torre
c3b38b2f60 Merge pull request #865 from CartoDB/perf-boost-agg-dataview
Improve the speed of the aggregation dataview
2018-02-13 09:04:00 +01:00
Rafa de la Torre
b4e06ec1ac Update NEWS.md and stub version 2018-02-12 19:35:34 +01:00
Rafa de la Torre
d0a8bd428f Merge remote-tracking branch 'origin/master' into perf-boost-agg-dataview 2018-02-12 19:33:35 +01:00
Rafa de la Torre
251fe96509 Cosmetic fix, as suggested in PR 2018-02-12 19:24:53 +01:00
Rafa de la Torre
065f56e161 Improve the speed of the aggregation dataview
Improve the performance of the aggregation dataview.

Instead of using a CTE (WITH) for filtered_source, which is only used in
one place to calculate ranks, inject it as a subquery.

This way the planner has a chance to ignore uneeded columns as well as
to parallelize the exectution of the window function (WindowAgg in the
query plan).

That is the part that takes most of the time of the query.

The improvement is about 20-40% in speed on PG10 with 4 cores.
2018-02-07 18:10:13 +01:00
3 changed files with 17 additions and 16 deletions

View File

@@ -1,5 +1,9 @@
# Changelog
## 5.3.1
Released 2018-02-13
- Improve the speed of the aggregation dataview #865
## 5.3.0
Released 2018-02-12
- Upgrades redis-mpool to 0.5.0

View File

@@ -2,19 +2,17 @@ const BaseDataview = require('./base');
const debug = require('debug')('windshaft:dataview:aggregation');
const filteredQueryTpl = ctx => `
filtered_source AS (
SELECT *
FROM (${ctx.query}) _cdb_filtered_source
${ctx.aggregationColumn && ctx.isFloatColumn ? `
WHERE
${ctx.aggregationColumn} != 'infinity'::float
AND
${ctx.aggregationColumn} != '-infinity'::float
AND
${ctx.aggregationColumn} != 'NaN'::float` :
''
}
)
SELECT *
FROM (${ctx.query}) _cdb_filtered_source
${ctx.aggregationColumn && ctx.isFloatColumn ? `
WHERE
${ctx.aggregationColumn} != 'infinity'::float
AND
${ctx.aggregationColumn} != '-infinity'::float
AND
${ctx.aggregationColumn} != 'NaN'::float` :
''
}
`;
const summaryQueryTpl = ctx => `
@@ -43,7 +41,7 @@ const rankedCategoriesQueryTpl = ctx => `
${ctx.column} AS category,
${ctx.aggregationFn} AS value,
row_number() OVER (ORDER BY ${ctx.aggregationFn} desc) as rank
FROM filtered_source
FROM (${filteredQueryTpl(ctx)}) filtered_source
${ctx.aggregationColumn !== null ? `WHERE ${ctx.aggregationColumn} IS NOT NULL` : ''}
GROUP BY ${ctx.column}
ORDER BY 2 DESC
@@ -134,7 +132,6 @@ const aggregationFnQueryTpl = ctx => `${ctx.aggregation}(${ctx.aggregationColumn
const aggregationDataviewQueryTpl = ctx => `
WITH
${filteredQueryTpl(ctx)},
${summaryQueryTpl(ctx)},
${rankedCategoriesQueryTpl(ctx)},
${categoriesSummaryMinMaxQueryTpl(ctx)},

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "windshaft-cartodb",
"version": "5.3.0",
"version": "5.3.1",
"description": "A map tile server for CartoDB",
"keywords": [
"cartodb"