Uploaded image for project: 'COmanage'
  1. COmanage
  2. CO-2711

slow DB query performance with cm_identifiers table

    XMLWordPrintable

Details

    Description

      I am seeing slow performance with a DB query against the cm_identifiers table with a query that is run multiple times during an Org Identity Source pipeline when creating a new COperson.

      Below is the query. For one new person, this query was run 12 times with various co_group_id in the WHERE clause.  I saw 4 different co_group_ids used, and each one was queried 3 times.

      SELECT "Identifier"."id" AS "Identifier__id",
      "Identifier"."identifier" AS "Identifier__identifier",
      "Identifier"."type" AS "Identifier__type",
      "Identifier"."login" AS "Identifier__login",
      "Identifier"."status" AS "Identifier__status",
      "Identifier"."co_person_id" AS "Identifier__co_person_id",
      "Identifier"."org_identity_id" AS "Identifier__org_identity_id",
      "Identifier"."co_department_id" AS "Identifier__co_department_id",
      "Identifier"."co_group_id" AS "Identifier__co_group_id",
      "Identifier"."organization_id" AS "Identifier__organization_id",
      "Identifier"."source_identifier_id" AS "Identifier__source_identifier_id",
      "Identifier"."co_provisioning_target_id" AS "Identifier__co_provisioning_target_id",
      "Identifier"."created" AS "Identifier__created",
      "Identifier"."modified" AS "Identifier__modified",
      "Identifier"."identifier_id" AS "Identifier__identifier_id",
      "Identifier"."revision" AS "Identifier__revision",
      "Identifier"."deleted" AS "Identifier__deleted",
      "Identifier"."actor_identifier" AS "Identifier__actor_identifier"
      FROM "public"."cm_identifiers" AS "Identifier"
      WHERE "Identifier"."identifier_id" IS NULL 
      AND "Identifier"."deleted" IS NOT true 
      AND "Identifier"."co_group_id" = 5;

       

      Creating an index on the co_group_id column in the cm_identifiers table resolves the performance problem.  This query goes from taking 5-6 seconds to execute down to milliseconds to execute.

      example SQL I used to create the new index:

      CREATE INDEX cm_identifiers_wfu_i1 ON public.cm_identifiers USING btree (co_group_id);

      Attachments

        Activity

          People

            benn.oshrin@at.internet2.edu Benn Oshrin (internet2.edu)
            s.s@at.internet2.edu Seth Stein
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: