slow query processing

Bob sql 476 Reputation points
2023-03-31T11:25:46.0766667+00:00

Hi Experts,

Yesterday, we ran a program and it has processed 1500 records in 2 min.

Today, it is running for past 90 minutus and processed only 350 records so far.

What should be checked apart from blocking?

Cheers,

Bob

SQL Server Other
{count} votes

Accepted answer
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2023-04-05T21:14:05.92+00:00

    I note that the table MDM_TRUST_SCORE does not have any primary key defined. What happens if you do:

    ALTER TABLE MDM_TRUST_SCORE ALTER COLUMN SOURCE_SYSTEM nvarchar(50) NOT NULL
    ALTER TABLE MDM_TRUST_SCORE ALTER COLUMN TYPE nvarchar(50) NOT NULL
    ALTER TABLE MSM_TRUST_SCORE ADD CONSTRAINT pk_MDM_TRUST_SCORE PRIMARY KEY (TYPE, SOURCE_SYSTEM)
    
    

    If the ALTER COLUMN operations fails because of NULL values, try this instead:

    CREATE UNIQUE INDEX type_source_system_ix ON MDM_TRUST_SCORE (TYPE, SOURCE_SYSTEM) WHERE TYPE IS NOT NULL AND SOURCE_SYSTEM IS NOT NULL
    

    If any of these fails because values are not unique, you have something to investigate, because the query seems to be written with the assumption that this combo is unique.

    The table C_B_PARTY_COMM could benefit from a composite index on (PARTY_ID, COMM_USG, COMM_TYP_CD). (There are single-column indexes on all three columns, but that is not really the same thing.) Of these columns, you should put the most selective column first. That is, the column with the highest number of distinct values.

    The index SVR1_1XSE on C_B_PARTY_COMM_XREF could be augmented to include the columns LAST_UPDATE_DATE and REF_PHONE_VERBOSE_STS.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.