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

pull/10819/head
fangfang.dong 1 year ago
parent b2bff22387
commit d7d554daf5

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

Loading…
Cancel
Save