How to get the number of users, groups, and nested groups in Bitbucket Data Center and Server?

お困りですか?

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

コミュニティに質問

プラットフォームについて: 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 は除く

目的

The number of users and groups, and the depth of nested groups can contribute to performance and other stability problems in your instance.  However, it can be difficult to find out the exact number of users and groups being synched from your LDAP directory, especially if you have nested groups. 

ソリューション

If you experience problems, or you want to make sure you don't exceed our recommended guardrails, you can use the following queries to check the total number users and groups. 

These queries have been tested with PostgreSQL, Oracle 12c, and Microsoft SQL Server 2017.

Get the total number of groups

Use this query to find out the total number of groups in the instance.

PostgreSQL / Oracle
SELECT DISTINCT count(*) 
AS group_count
FROM cwd_group; 
MS SQL
SELECT DISTINCT count(*) 
as group_count
FROM [bitbucketschema].cwd_group;

Get the total number of users

Use this query to find out the total number of users in the instance.  

PostgreSQL / Oracle
SELECT DISTINCT count(lower_email_address) 
AS user_count
FROM cwd_user; 
MS SQL
SELECT DISTINCT count(lower_email_address) 
as user_count
FROM [bitbucketschema].cwd_user;

Get the depth of nested groups

Use this query to find the depth of nested groups in the instance.

PostgreSQL
with recursive group_hierarchy as (
select
    child_id,
    parent_id,
    parent_name,
           1 as depth_of_nested_groups
from
    cwd_membership
where
    cwd_membership.membership_type = 'GROUP_GROUP'
union all
select
    cwd_membership.child_id,
    cwd_membership.parent_id,
           cwd_membership.parent_name,
           depth_of_nested_groups + 1
from
    cwd_membership
join group_hierarchy on
    group_hierarchy.parent_id = cwd_membership.child_id
where
    cwd_membership.membership_type = 'GROUP_GROUP'
)

select
    *
from
    group_hierarchy
Oracle
with group_hierarchy(child_id, parent_id, parent_name, depth) as (
select
    child_id,
    parent_id,
    parent_name,
           1 as depth
from
    cwd_membership
where
    cwd_membership.membership_type = 'GROUP_GROUP'
union all
select
    cwd_membership.child_id,
    cwd_membership.parent_id,
    cwd_membership.parent_name,
           depth + 1
from
    cwd_membership
join group_hierarchy on
    group_hierarchy.parent_id = cwd_membership.child_id
where
    cwd_membership.membership_type = 'GROUP_GROUP'
)

select
    *
from
    group_hierarchy;
MS SQL
with group_hierarchy as (
select
    child_id,
    parent_id,
    parent_name,
           1 as depth_of_nested_groups
from
    cwd_membership
where
    cwd_membership.membership_type = 'GROUP_GROUP'
union all
select
    cwd_membership.child_id,
    cwd_membership.parent_id,
    cwd_membership.parent_name,
           depth_of_nested_groups + 1
from
    cwd_membership
join group_hierarchy on
    group_hierarchy.parent_id = cwd_membership.child_id
where
    cwd_membership.membership_type = 'GROUP_GROUP'
)

select
    *
from
    group_hierarchy



説明 How to get the number of users, groups, and nested groups in Bitbucket Data Center and Server?
製品Bitbucket
最終更新日 2022 年 11 月 30 日

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

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