On 12/08/2010 9:48 a.m., Brendan Brink wrote:
Hi there,
I am trying to run more complex searches on a database and the user
keeps timing out.
select distinct(e.id) from table1 e , table2 es1 , table2 es2 , table2
es3 , table2 es4 , table2 es5 where 1 and e.first_name != '' and
e.last_name != '' and es1.employee_id = e.id and es1.skill = 'Forklift
Driver' and es2.employee_id = e.id and es2.skill = 'Arc Welder' and
es3.employee_id = e.id and es3.skill = 'Blender' and es4.employee_id =
e.id and es4.skill = 'Charge Hand' and es5.employee_id = e.id and
es5.skill = 'Assembly Work' order by e.last_name,e.first_name
table2 stores attributes of items in table 1 and items in table1 can
have more than one attribute in table 2.
You probably need to add indexes to at least table2.employee_id and
table2.skill. Add 'explain ' in front of your query and have a look at
the result.
--
TIM OLIVER
Software Engineer
158 Leinster Road, Merivale, PO Box 36578
Christchurch 8146, New Zealand
P +64 3 377 0007 F +64 3 353 1308 E [email protected]
E2DIGITAL.CO.NZ
--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]