Rails rendering takes too long

  question, ruby

In an api request, the rails server prints the following message, which is the operation time of each database table (totally 67.5ms), but the rendering of Views takes 450 ms. I don’t know why it takes so long.
Can it take that long to extract data from the database and serialize it into json format?

...
 [active_model_serializers] Rendered ActiveModel::Serializer::CollectionSerializer with ActiveModelSerializers::Adapter::Attributes (457.64ms)
 Completed 200 OK in 612ms (Views: 450.0ms | ActiveRecord: 67.5ms)

Finally, paste the serializer definition (with many associated attributes):

1 class TopicSerializer < TopicStatisticsSerializer
 2   attributes :cover, :selected_at
 3   has_one :hot, if: :is_admin_user?  , serializer: HotSimpleSerializer
 4   has_one :user, serializer: UserSimpleSerializer
 5   belongs_to :sticker, serializer: StickerSerializer
 6   has_many :categories, serializer: CategorySimpleSerializer

It’s really possible. Generally speaking, the bottleneck of web application will appear in db, but rails will appear in view, so you need cache!