2024-09-29 21:34:37 发布
网友
我正在使用ListAPIView来呈现对象列表。响应返回带limit=50的分页结果。查询集大小从0到几十万不等。在
ListAPIView
limit=50
我注意到的是,当queryset很小时,API响应时间很短。但是随着queryset大小的增加,API响应时间变得非常大。在
分页真的是罪魁祸首吗? 有没有一种方法可以使用分页优化ListAPIViews的响应时间?在
如django官方文档所述,querysets are lazy。
QuerySets are lazy – the act of creating a QuerySet doesn’t involve any database activity. You can stack filters together all day long, and Django won’t actually run the query until the QuerySet is evaluated.
还有,pagination compliments queryset's laziness。在
因此,延迟的culprit不是分页。 结案。。。在
但那又是什么呢?在
Ordering
怎样才能更快?在
如django官方文档所述,querysets are lazy。
还有,pagination compliments queryset's laziness。在
因此,延迟的culprit不是分页。
结案。。。在
但那又是什么呢?在
Ordering
正如@sha256建议的那样。在怎样才能更快?在
相关问题 更多 >
编程相关推荐