Fix by_parent filter to filter by project_namespace_id instead of project_id

In #536351 (closed), we updated the logic so that the main query in the issues / work items finder uses project_namespace_id to join items to the projects table, instead of the project_id.

It was found while testing an unrelated feature that when the project filter filters items by project_id after the join, the planner uses a suboptimal query, resulting in poor performance: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/42731/commands/130800.

When the filter is switched to using project_namespace_id instead, the performance improves significantly: https://console.postgres.ai/gitlab/gitlab-production-main/sessions/42748/commands/130875

Proposal

Update the logic in the filter_by_namespace method to filter items by the project_namespace_id, instead of the project_id. Something like this might work: idea.patch

Edited by 🤖 GitLab Bot 🤖