Resolve "Deleting a project results in a large number of SQL requests that could be optimized"

What does this MR do?

Are there points in the code the reviewer needs to double check?

Why was this MR needed?

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes #1163 (moved)