Python Django查询的游标速度很慢

Python Django查询的游标速度很慢,python,django,Python,Django,在Djando中使用cursor(不使用orm,因为它需要更多时间),在mysql中直接使用cursor需要4或5秒,我认为这可能会影响到一些查询,这些查询需要15秒(很多) cursor = connection.cursor() cursor.execute("select m.ub ,m.eq , MONTH(m.fecha) as fecha, AVG(m.cantidad) as cantidad , e.contt from mytable as m left join table

在Djando中使用cursor(不使用orm,因为它需要更多时间),在mysql中直接使用cursor需要4或5秒,我认为这可能会影响到一些查询,这些查询需要15秒(很多)

cursor = connection.cursor()
cursor.execute("select m.ub ,m.eq , MONTH(m.fecha) as fecha,
AVG(m.cantidad) as cantidad , e.contt from mytable as m 
left join table2 as e on e.id = m.equipo_id where m.equipo_id = %s and m.udm = 8 and 
YEAR(m.fecha) = %s  GROUP BY MONTH(m.fecha)",[eq,anio])

我记得使用年份或月份时,结果很慢,特别是在以下情况下,取决于列中数据的一致性,也许您可以避免使用它或使用regex?我不知道这是否是django cursor对mysql的问题,因为在mysql 4查询中,这是非常快的,如果4个问题与进程有关,我会尝试使用一个cursor,并且mysql配置它以允许多个连接的时间太长@埃多瓦多夫切内利