Query results taking too long on 200K database, speed up tips?
Posted
by colorfulgrayscale
on Stack Overflow
See other posts from Stack Overflow
or by colorfulgrayscale
Published on 2010-04-17T01:10:52Z
Indexed on
2010/04/17
1:13 UTC
Read the original article
Hit count: 499
I have a sql statement where I'm joining about 4 tables, each with 200K rows. The query runs, but keeps freezing. When I do a join on 3 tables instead, it returns the rows (takes about 10secs). Any suggestion why? suggestions to speed up?
Thanks!
Code
SELECT *
FROM equipment, tiremap, workreference, tirework
WHERE equipment.tiremap = tiremap.`TireID` AND tiremap.`WorkMap` = workreference.`aMap` AND workreference.`bMap` = tirework.workmap
LIMIT 5
p.s
and if it helps any, I'm using sql alchemy to generate this code, the sqlalchemy code for this is
query = session.query(equipment, tiremap, workreference, tirework)
query = query.filter(equipment.c.tiremap == tiremap.c.TireID)
query = query.filter(tiremap.c.WorkMap==workreference.c.aMap)
query = query.filter(workreference.c.bMap == tirework.c.workmap)
query = query.limit(5)
query.all()
© Stack Overflow or respective owner