1

Is there a limit for the number of annotations on a queryset? Will there be a significant performance hit if I add lots of (over 50) annotations to a queryset?

user4426017
  • 1,930
  • 17
  • 31

2 Answers2

2

Well, it depends upon the situation. As @Bear Brown mentioned annotation is just the calculation on DB level and each calculation makes your query slower so it affects the performance in general but it doesn't necessarily mean that your query will be slow with 50+ annotations.

On the one hand if you have enormous big data set then sometimes even few annotations (calculations on db level) can cause the slowness, while on the other hand, with small data set you can put a lot of annotations and you would not notice any slowness. You basically need to think about the approximately maximum number of records that your data set will have and try to test it if possible.

T.Tokic
  • 1,264
  • 9
  • 10
1

No limit for annotation at all. But for performance you should understand that annotation it is just calculation on db side no more, and of course each calculation doing your query slower.

Brown Bear
  • 19,655
  • 10
  • 58
  • 76