unep-grid / mapx

MapX
https://app.mapx.org
Other
86 stars 22 forks source link

Metadata panel takes longer to load #990

Closed thomaspiller closed 4 months ago

thomaspiller commented 4 months ago

This could come from the SQL query to generate the view reading stats. Another thing to look into is the change of cloud provider that occurred in early April. This should be investigated ASAP.

PierreLacroix commented 4 months ago

Option: add a button that displays on demand the statistics by country

fxi commented 4 months ago

After a bit of research on the results with EXPLAIN/ANALYZE, I was able to improve by 15 folds the speed of the query, by creating an index :

CREATE INDEX mx_logs_id_log_data_date_idx
ON mx_logs (id_log, (data #>> '{"id_view"}'), date_modified);

Added in prod and staging. If it's fast enough now, we can close this issue and I'll include that in the next migration script.

fxi commented 4 months ago

I think I found another bottleneck during the stats process, for popular views with thousands of activations. I will try to find another trick before closing.