更新时间:2023-01-30 22:01:20
挂起可能涉及MySQL表本身,而不涉及Python代码.它们包含很多记录吗?他们的桌子很宽吗?它们是否在datetime_field上建立索引?
Hanging could involve the MySQL tables themselves and not specifically the Python code. Do they contain many records? Are they very wide tables? Are they indexed on the datetime_field?
考虑各种策略:
具体选择所需的列而不是星号,从而调用所有列.
Specifically select the needed columns instead of the asterisk, calling all columns.
DBR_DATETIME_FIELD
上的索引,用于where子句(即隐式连接).
Index on the DBR_DATETIME_FIELD
being used in the where clause (i.e., implicit join).
使用打印的计时器print(datetime.datetime.now())
进一步诊断,以查看哪些是瓶颈表.为此,请确保导入datetime
模块.
Diagnose further with printed timers print(datetime.datetime.now())
to see which are the bottleneck tables. In doing so, be sure to import the datetime
module.