Reset counter cache on all data of model

To update all the counter cache in one request I found inspiration on http://ryan.mcgeary.org/2016/02/05/proper-counter-cache-migrations-in-rails/

It can be done in one request with SQL :

ActiveRecord::Base.connection.execute <<-SQL.squish
    UPDATE games
    SET game_participations_count = (SELECT count(1)
                               FROM game_participations
                              WHERE game_participations.game_id = games.id)
SQL

It takes much less time to execute since all the updating is done in one request.