Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
具体来说,我使用的是 Django 模型。
1)MyModel.objects.filter(created_time__lte=timezone.now())
MyModel.objects.filter(created_time__lte=timezone.now())
VS
2)MyModel.objects.filter(created_time__lte=timezone.now().replace(second=0))
MyModel.objects.filter(created_time__lte=timezone.now().replace(second=0))
2)是否优于1),不考虑准确性,因为2)似乎会撞到mysql的缓存?
谢谢!
如果查询将在不到 1 分钟的时间内执行,则第二个将更有效。
无论如何,你需要大量的流量才能通过这样做来真正获得一些东西
“过早优化是万恶之源”