Welcome Guest, Not a member yet? Register   Sign In
Mysql hanging
#1

[eluser]megabyte[/eluser]
I have a search query using a join.

Code:
SELECT * FROM work_orders  

LEFT JOIN

customers using (Cid)

WHERE


customers.Name LIKE 'f51%' OR
customers.Address LIKE 'f51%'  OR
customers.Tel LIKE 'f51%' OR
work_orders.Site_Address LIKE 'f51%' or

customers.Name LIKE '%Wiltshire%' OR
customers.Address LIKE '%Wiltshire%' OR
customers.Tel LIKE '%Wiltshire%' or
work_orders.Site_Address LIKE '%Wiltshire%'

Group By customers.Cid






SELECT * FROM customers  

LEFT JOIN

work_orders using (Cid)

WHERE


customers.Name LIKE 'f51%' OR
customers.Address LIKE 'f51%'  OR
customers.Tel LIKE 'f51%' OR
work_orders.Site_Address LIKE 'f51%' or

customers.Name LIKE '%Wiltshire%' OR
customers.Address LIKE '%Wiltshire%' OR
customers.Tel LIKE '%Wiltshire%' or
work_orders.Site_Address LIKE '%Wiltshire%'

Group By customers.Cid

Almost identical queries, just the join changes, however the first one executes in about 2 seconds and the second hangs forever and never finishes. I'm using phpmyadmin to test these queries.

Does anyone have a clue why this would happen?

Both tables have about 6,000 rows of data.
#2

[eluser]Kepler[/eluser]
You may want to try creating an index on work_orders.Cid

If that doesn't help, try grouping by work_orders.Cid in the second query.




Theme © iAndrew 2016 - Forum software by © MyBB