Skip to content

Avoid unnecessary series type queries#472

Merged
bpepple merged 1 commit intoMetron-Project:masterfrom
jyggen:fix-n1-query
Mar 6, 2026
Merged

Avoid unnecessary series type queries#472
bpepple merged 1 commit intoMetron-Project:masterfrom
jyggen:fix-n1-query

Conversation

@jyggen
Copy link
Copy Markdown
Contributor

@jyggen jyggen commented Mar 5, 2026

The access to series_type.id causes the related series type to be queried every time an issue or series is turned into its string representation, which can results in dozens of additional queries on some views. Since only id is accessed, __str__ can be optimized into using series_type_id instead, which avoids the additional query altogether.

@bpepple bpepple self-assigned this Mar 5, 2026
@bpepple bpepple added the enhancement New feature or request label Mar 6, 2026
Copy link
Copy Markdown
Member

@bpepple bpepple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. This change should avoid any unnecessary DB queries every time these models are stringified (e.g., in admin lists, logging, API serialization, etc.) where the related object is not already cached in the ORM. Thx!

@bpepple bpepple merged commit 0e6fac0 into Metron-Project:master Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants