我试图让jsonb性能与包含相同数据的联接表的性能相匹配。到目前为止一直很好,但我仍然坚持下面的分组查询,它在大约1.6秒内返回:
.gitignore
表格版本在0.8秒内返回:
SELECT
x.metadata #>> '{fakeWeather, windDirection}' as wind_direction,
COUNT(*) as count
FROM analytics.incidents x
GROUP BY x.metadata #>> '{fakeWeather, windDirection}'
ORDER BY 1;
我创建了以下索引:SELECT
y.wind_direction,
COUNT(*) as count
FROM analytics.incidents x
INNER JOIN analytics.incidents_metadata_fakeweather y ON x."id" = y.incident_id
GROUP BY y.wind_direction
ORDER BY 1;
有人知道如何(或者如果)我可以更快地制作JSONB版本吗?