How to check which custom fields have global contexts and default values and aren't associated with any screens

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Fisheye および Crucible は除く

    

目的

Custom fields, when not used wisely and not governed properly, can put a lot of strain on Jira's performance. 

The good news is that you can be proactive with custom fields. Checkout Managing custom fields in Jira effectively to know how. 

If you're thinking of optimizing custom fields, checkout Optimizing custom fields

Since the custom field optimizer doesn't check for the existence of the fields in screens or whether or not the fields have default values, the query below may come in handy. 

ソリューション

The query below was written by Atlassian Support on best-effort basis for PostgreSQL. It is not officially supported by Atlassian and requests to rewrite it for a specific DBMS may not be fulfilled. 

The query will return custom fields info and the number of tickets this custom field is set in. 

Once you get the result of the query, make sure you validate that the fields reported do indeed satisfy all those conditions and proceed with the cleanup actions (removing default values, creating project-based contexts, etc...)

SELECT cf.id, cf.cfname, COUNT(cfv.issue)
FROM customfield cf
    LEFT JOIN customfieldvalue cfv ON cf.id = cfv.customfield
WHERE cf.id IN
    (
    SELECT DISTINCT SUBSTRING(ct.customfield, 13)::INTEGER 
    FROM configurationcontext ct 
        INNER JOIN fieldconfigscheme fcs ON ct.customfield = fcs.fieldid 
        INNER JOIN genericconfiguration gc ON fcs.id::CHAR(60) = gc.datakey 
        -- Field has a default value
    WHERE gc.datatype = 'DefaultValue' 
        AND ct.customfield LIKE 'customfield_%' 
        -- Context is global
        AND ct.project IS NULL
        -- Field is not present in any screen
        AND ct.customfield NOT IN (SELECT fieldidentifier
                                   FROM fieldscreenlayoutitem)
    )
GROUP BY cf.id;

最終更新日 2021 年 7 月 26 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.