like i said in the title i have a SQL query that joins many tables and uses CASE WHEN to return the progress of the projects
SELECT
p.id_project
CASE
WHEN po.id is not null then 'payement commpleted'
WHEN b.id is not null then 'bill recieved'
WHEN e.id is not null then 'project engaged'
(and still many other cases)
ELSE 'start of the project'
END as progress
FROM project p
left join decision d on d.id_project=p.id_project
LEFT JOIN engagement e on e.id_project=p.id_project
LEFT JOIN bill b on b.id_project=p.id_project
LEFT JOIN payment_order po on po.id_project=p.id_project
LEFT JOIN ..... (many other tables)
needless to say that not all joins are simple joins and not all the cases are simple cases, in fact most of them are complicated, the query takes about 1 sec to execute and when i remove the CASE column entirely it goes down to about .3 sec, the 1 sec query is still too much as it needs to be called in other queries. now i don't know if i can optimize the query more or not or if there is a better approach but any suggestions would be appreciated.