I have this pretty simple SQL query
SELECT v.*, u.user_company as company_name, o.`name` as object_name,
o.address as object_address, i.id as installation_id, i.`name`
as installation_name FROM maintenance as v, users as u,t_local as o,
t_local_objects as i WHERE o.active=1 AND v.done IS NOT NULL
The biggest table - maintenance, it has about 3k records, the others have around 300, which isn't really that much. When I execute it, I get a memory overload (tried to allocate over 130MB). How to optimize the query?
The tables will grow bigger in time, so it has to be valid for over 10k records in maintenance.