query performance review - 2 - 19 of November 2019
We have the following query that is generating expressive load on the replicas ( 10% of the cpu time from all the replicas in average) :
---WITH RECURSIVE "base_and_descendants" AS (SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."type" IN (?) AND (EXISTS (SELECT ? FROM "plans" INNER JOIN "gitlab_subscriptions" ON "gitlab_subscriptions"."hosted_plan_id" = "plans"."id" WHERE "plans"."name" IN (?, ?) AND (gitlab_subscriptions.namespace_id = namespaces.id)))UNIONSELECT "namespaces".* FROM "namespaces", "base_and_descendants" WHERE "namespaces"."type" IN (?) AND "namespaces"."parent_id" = "base_and_descendants"."id") SELECT "namespaces".* FROM "base_and_descendants" AS "namespaces" WHERE "namespaces"."id" = ? LIMIT ?
---
Please consider using the binding variables.
Edited by Jose Finotto