Skip to content

Avoid N+1 query in Tag#tagnames_as_classes #11853

@koushik-luffy

Description

@koushik-luffy

I noticed that Tag#tagnames_as_classes performs a Node.find(id) call,
which can lead to N+1 queries when rendering tag lists.

Since Tag already has a node association, this can be rewritten to
use the association and allow eager loading with .includes(:node).

This would improve performance without changing behavior.

I’d like to work on this if that’s okay.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions