django的惰性查询
django中的查询,在写好查询条件之后,在不调用变量的时候,sql是不会执行的,只有在调用变量的时候,才回去执行,
在一次查询之后,会把变量放进内存,下次再使用这个变量的时候就会使用内存汇总的值。
django的惰性查询
可以看到,两次时间相差很大。

在python manage.py shell中进行查询,有种例外
taskHistories3 = TaskHistory.objects.only('createTime', 'result_0').order_by('-createTime')[:5]

django的惰性查询
这种是没有缓存的,

又缓存的是这种的
django的惰性查询

因为:
Simply printing the queryset will not populate the cache. This is because the call to repr() only returns a slice of the entire queryset.
简单地打印queryset将不会填充缓存。这是因为对repr__()的调用只返回整个queryset的一部分。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2022-02-16
  • 2021-09-03
猜你喜欢
  • 2021-10-21
  • 2021-05-28
  • 2022-12-23
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案