perf: 接口sql优化 /api/v1/assets/assets/

pull/10819/head
fangfang.dong 2023-06-25 18:08:59 +08:00
parent b2bff22387
commit d7d554daf5
1 changed files with 4 additions and 0 deletions

View File

@ -121,6 +121,10 @@ class AssetViewSet(SuggestionMixin, NodeFilterMixin, OrgBulkModelViewSet):
NodeFilterBackend, AttrRulesFilterBackend
]
def get_queryset(self):
return super().get_queryset().prefetch_related('nodes', 'protocols')\
.select_related('platform', 'domain', 'host')
def get_serializer_class(self):
cls = super().get_serializer_class()
if self.action == "retrieve":