tidb icon indicating copy to clipboard operation
tidb copied to clipboard

query information_schema.ddl_jobs is very slow

Open 3AceShowHand opened this issue 1 year ago • 1 comments

Feature Request

Is your feature request related to a problem? Please describe:

We'd like to query the tidb to know the ddl job status, by running the following query, it takes more than 20 seconds return the result, it's too slow.

SELECT JOB_ID, JOB_TYPE, SCHEMA_STATE, SCHEMA_ID, TABLE_ID, STATE, QUERY
FROM information_schema.ddl_jobs
WHERE DB_NAME = "%s" 
    AND TABLE_NAME = "%s"
    AND JOB_TYPE LIKE "add index%%"
    AND (STATE = "running" OR STATE = "queueing")
LIMIT 1;

Describe the feature you'd like:

The query above should return result very quick.

Describe alternatives you've considered:

Teachability, Documentation, Adoption, Migration Strategy:

3AceShowHand avatar Aug 28 '24 09:08 3AceShowHand

ref https://github.com/pingcap/tiflow/issues/11521

3AceShowHand avatar Aug 28 '24 09:08 3AceShowHand