[Answer]-Query proformance on GenericForeignKey Django

1👍

select_related() can’t prefetch generic relations (it works only with ForeignKey and OneToOneField), so You may need to write a raw SQL query if You really want to reduce this one additional query.

In case of fetching many messages at once You may use prefetch_related() which can follow generic relations (but still makes an additional query).

Leave a comment