Skip to content

Optimize index_should_be_marked_as_orphaned_check with a single batch

What does this MR do and why?

The task index_should_be_marked_as_orphaned_check now processes just one batch of indices on a single run. This will allow more controlled updating of indices and database transactions.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Query Plan

UPDATE
    "zoekt_indices"
SET
    "state" = 230
WHERE
    "zoekt_indices"."id" IN (
        SELECT
            "zoekt_indices"."id"
        FROM
            "zoekt_indices"
        WHERE ("zoekt_indices"."zoekt_enabled_namespace_id" IS NULL
            OR "zoekt_indices"."zoekt_replica_id" IS NULL)
        AND "zoekt_indices"."state" NOT IN (230, 240)
    ORDER BY
        "zoekt_indices"."id" ASC
    LIMIT 1000)

https://console.postgres.ai/shared/71560d69-85aa-4c13-b683-03155d54b3c7

SELECT
    1 AS one
FROM
    "zoekt_indices"
WHERE ("zoekt_indices"."zoekt_enabled_namespace_id" IS NULL
    OR "zoekt_indices"."zoekt_replica_id" IS NULL)
AND "zoekt_indices"."state" NOT IN (230, 240)
LIMIT 1

https://console.postgres.ai/shared/143845d0-d18a-45b7-a5a4-1e103c5ec824

Related to #511076

Edited by Ravi Kumar

Merge request reports

Loading