• Author Maintainer

    I've made an optimization by pushing down the filters:

    EXPLAIN (ANALYZE, BUFFERS)
    WITH "restricted_job_artifacts" AS (
            SELECT
                    "gitlab_secondary"."ci_job_artifacts"."id"
            FROM
                    "gitlab_secondary"."ci_job_artifacts"
            WHERE   ("gitlab_secondary"."ci_job_artifacts"."file_store" = 1
                  OR "gitlab_secondary"."ci_job_artifacts"."file_store" IS NULL)
                 AND(expire_at IS NULL
                  OR expire_at > '2019-11-08 18:30:46.473416')
                 AND
                    "gitlab_secondary"."ci_job_artifacts"."project_id" IN(
                            SELECT
                                    "gitlab_secondary"."projects"."id" FROM "gitlab_secondary"."projects"
                            WHERE
                                    "gitlab_secondary"."projects"."namespace_id" IN(WITH RECURSIVE "base_and_descendants" AS ((
                                                    SELECT
                                                            "gitlab_secondary"."geo_node_namespace_links"."namespace_id" AS id FROM "gitlab_secondary"."geo_node_namespace_links"
                                                    WHERE
                                                            "gitlab_secondary"."geo_node_namespace_links"."geo_node_id" = 2)
                                            UNION (
                                                    SELECT
                                                            "gitlab_secondary"."namespaces"."id" FROM "gitlab_secondary"."namespaces",
                                                            "base_and_descendants"
                                                    WHERE
                                                            "gitlab_secondary"."namespaces"."parent_id" = "base_and_descendants"."id"))
                                    SELECT
                                            "id" FROM "base_and_descendants" AS "gitlab_secondary_namespaces"))
    )
    SELECT
            "restricted_job_artifacts"."id"
    FROM
            "restricted_job_artifacts"
            LEFT OUTER JOIN "job_artifact_registry" ON "restricted_job_artifacts"."id" = "job_artifact_registry"."artifact_id"
    AND "job_artifact_registry"."id" IS NULL AND 1 = 1
    LIMIT 1000;

    The result is here: https://explain.depesz.com/s/CKGn

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment