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
Also patching the relation class to introduce the methods:
Content.class_evaldohas_many:likes_per_hour,foreign_class: Like::PerHourhas_many:likes_per_dayscope:total_likes_count,->{select("sum(count) as total")}endcontent=Content.firstcontent.total_likes_count# => "select sum(count) as total from likes_daily where content_id = $1"content.likes_hourly# => "select * from likes_hourly where content_id = $1"content.likes_daily# => "select * from likes_daily where content_id = $1"
The text was updated successfully, but these errors were encountered:
Counter caches are interesting but they have a serious problem of bringing vacuum issues:
See more about the benefits of this denormalization:
https://thoughtbot.com/blog/what-is-counter-cache#counter-cache-to-the-rescue
But there are some issues with this approach too:
https://www.timescale.com/blog/counter-analytics-in-postgresql-beyond-simple-data-denormalization/
Now, let's think about introducing it to the timescaledb gem to track such events on a hypertable and migrate counter caches to continuous aggregates.
Syntax Ideas:
Automatic:
Configurable:
Behind the scenes it can find or build a continuous aggregates for it. Injecting some code like this:
Also patching the relation class to introduce the methods:
The text was updated successfully, but these errors were encountered: