You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After doing a lot of DB testing (check the server/src/query_testing folder ) it seems the main slowdown for the views, especially the post_view, is that it needs to run the function `hot_rank(sum of a likes join), published_time)
That hot_rank is causing the front page fetch to be over 300 ms. The goal is to try to get every fetch, especially the front page under 15 ms.
This should also create indexes on the views, and make sure there are triggers to make sure the materialized views are refreshed any time there are data updates to the underlying primary tables. Also be sure to use concurrently.
ab -c 10 -t 10 "https://dev.lemmy.ml/feeds/all.xml"
before:
Server Hostname: dev.lemmy.ml
Document Path: /feeds/all.xml
Requests per second: 3.78 [#/sec] (mean)
Time per request: 264.326 [ms] (mean, across all concurrent requests)
Transfer rate: 32.38 [Kbytes/sec] received
after:
Server Hostname: dev.lemmy.ml
Document Path: /feeds/all.xml
Requests per second: 32.17 [#/sec] (mean)
Time per request: 31.087 [ms] (mean, across all concurrent requests)
Transfer rate: 275.28 [Kbytes/sec] received
One problem tho is that this PR adds a lot of synchronous triggers to update the materialized views, IE, if you like a post, or create a comment, it tells those views to refresh. This only takes ~100ms but it still slows down all actions. If there's a way to do async postgres triggers, that'd be better.
#405
After doing a lot of DB testing (check the
server/src/query_testing
folder ) it seems the main slowdown for the views, especially thepost_view
, is that it needs to run the function `hot_rank(sum of a likes join), published_time)That hot_rank is causing the front page fetch to be over
300 ms
. The goal is to try to get every fetch, especially the front page under15 ms
.Performance :
This should also create indexes on the views, and make sure there are triggers to make sure the materialized views are refreshed any time there are data updates to the underlying primary tables. Also be sure to use concurrently.
Guide:
https://stackoverflow.com/questions/23906977/refresh-a-materialized-view-automatically-using-a-rule-or-notify
The text was updated successfully, but these errors were encountered: