Useful SQL Queries todo.png

Authors: VaughnRokosz, TimFeeney, BrianSteele, WilliamChatham
Build basis: 7.x

Page contents

This page contains some useful SQL queries to gather information from the DOORS Next (DN). Be advised that these queries can place load on the database so exercise caution and test these in a non-production environment first.
Note: The preferred output for the following scripts is CSV or TXT. No PDFs or XLS. Output each query result to its own file. Run these on systems that have been upgraded to 7.x.

Oracle

*The scripts will need to be changed to conform to your environment (e.g. change RMUSER to whatever user names are used for your environment).*

ArtifactsPerComponent.sql (Number of Artifacts per component):

select component_id, count (distinct item_id) as Comp 
from RMUSER.dngartifacts_db_artifact 
group by component_id order by Comp DESC;

-- Note: Query below is optional: If you require the component name you can use the Query below to dispaly the component name using the item_id returned from previous query above.

select NAME from RMUSER.vvcmodel_component 
where item_id='an item_id from previous query';

ArtifactsPerFolder.sql (Number of Artifacts per Folder):

select folder, count(folder) from
(
select distinct A.item_id as art, F.ITEM_ID as folder from RMUSER.dngartifacts_db_artifact A 
INNER JOIN RMUSER.DNGFOLDERS_DB_FOLDER F ON F.ITEM_ID = A.PARENT_FOLDER_ITEM_ID
) group by folder order by count(folder) desc fetch first 100 rows only

-- Note: Queries below are optional: If you want to get from the folder ID to the title, something like this should work:

SELECT DISTINCT ITEM_ID, TITLE FROM RMUSER.DNGFOLDERS_DB_FOLDER F 
WHERE F.ITEM_ID = 'uuid from previous query'

This will get better info on where the folder is at. However it only works on a single item id at a time

select distinct t1.item_id, t1.title, t3.name_col as project, t2.name_col as component from 
(select item_id, component_id, process_area_id, title from RMUSER.DNGFOLDERS_DB_FOLDER 
where item_id='item_id'
) t1 
inner join rmuser.vvcmodel_component t2 on t2.item_id = t1.component_id 
inner join rmuser.process_process_area t3 on t3.item_id = t1.process_area_id

ArtifactsPerModule.sql (Number of Artifacts per Module):

select module_item_id, count(distinct item_id) as count 
FROM rmuser.dngartifacts_db_binding_contnr TBL_2A 
group by module_item_id order by count desc;

-- Note: Queries below are optional: How would I convert module_item_id to an identifiable module, see below, if we have multiple item_id values, instead of " item_id = 'id' " you can use -- " item_id in ('id', 'id', 'id') "?

select distinct title from RMUSER.DNGARTIFACTS_DB_ARTIFACT where item_id = 'value of module_item_id'

This will get better info on where the module is at. It only works on a single module id at a time

select distinct t1.item_id, t1.id, t1.title, t3.name as project, t2.name as component from 
(select item_id, component_id, process_area_id, title, id 
       from rmuser.dngartifacts_db_artifact where item_id = 'module_item_id'
) t1 
inner join rmuser.vvcmodel_component t2 on t2.item_id = t1.component_id 
inner join rmuser.process_process_area t3 on t3.item_id = t1.process_area_id;

ArtifactsPerProject_v7.sql(Number of Artifacts per Project):

SELECT COUNT(*), PA.NAME FROM RMUSER.DNGARTIFACTS_DB_ARTIFACT A 
INNER JOIN RMUSER.PROCESS_PROCESS_AREA PA ON A.CONTEXT_ID = PA.ITEM_ID 
GROUP BY PA.NAME order by count(*) desc;

Artifactstates.sql (Artifact States):

select item_id, jz_discriminator, count(item_id) from rmuser.dngartifacts_db_artifact 
group by item_id, jz_discriminator having count(item_id) > 2 order by count(item_id);

ChangesetsPerStream.sql (Changesets per stream):

select S2.PARENT_STREAM_ITEM_ID, count(S2.PARENT_STREAM_ITEM_ID) 
from RMUSER.VVCMODEL_CHANGE_SET S2 
group by S2.PARENT_STREAM_ITEM_ID 
order by count(s2.PARENT_STREAM_ITEM_ID) desc

-- Note: Query below is optional: How would I convert S2.PARENT_STREAM_ITEM_ID to an identifiable stream?

select name from RMUSER.VVCMODEL_CONFIGURATION where item_id='value of parent_stream_id'

ComponentsPerProject.sql (Total number of Components per Project):

SELECT COUNT(*), PA.NAME FROM RMUSER.VVCMODEL_COMPONENT C 
INNER JOIN RMUSER.PROCESS_PROCESS_AREA PA 
ON C.PROJECT_AREA_ID = PA.ITEM_ID 
GROUP BY PA.NAME order by count(*) desc

ContributionsPerGC.sql (Number of Contributions per GC):

select composite_id, count(composite_id) from rmuser.repository_contributions 
group by composite_id order by count(composite_id) desc;

linksPerArtifact.sql (Number of Links per artifact):

select artifact, count(artifact) from 
(
select subject_item_item_id as artifact from rmuser.dnglinks_db_link 
union all
select object_item_item_id as artifact from rmuser.dnglinks_db_link
) group by artifact order by count(artifact) desc 

Warning This query could run long so be sure to first test this in a non-production environment.

streamsPerComponent.sql (Number of Streams per component):

select component_item_id, count(component_item_id) 
from rmuser.vvcmodel_configuration where type = 0 
group by component_item_id 
order by count(component_item_id) desc fetch first 100 rows only

tablespaceSizes.sql (Dispaly Table Space Sizes):

col "Tablespace" for a22
col "Used MB" for 99,999,999
col "Free MB" for 99,999,999
col "Total MB" for 99,999,999

select df.tablespace_name "Tablespace",
totalusedspace "Used MB",
(df.totalspace - tu.totalusedspace) "Free MB",
df.totalspace "Total MB",
round(100 * ( (df.totalspace - tu.totalusedspace)/ df.totalspace))
"Pct. Free"
from
(select tablespace_name,
round(sum(bytes) / 1048576) TotalSpace
from dba_data_files 
group by tablespace_name) df,
(select round(sum(bytes)/(1024*1024)) totalusedspace, tablespace_name
from dba_segments 
group by tablespace_name) tu
where df.tablespace_name = tu.tablespace_name ; 

totalArtifacts_v6.sql (Total Artifacts):

SELECT COUNT(distinct item_id) FROM RMUSER.DNGARTIFACTS_DB_ARTIFACT

totalArtifacts_v7.sql (Total Artifacts inclusive of states):

SELECT COUNT(*) FROM RMUSER.DNGARTIFACTS_DB_ARTIFACT

TotalComponents.sql (Count of all Components):

SELECT COUNT(*) FROM RMUSER.VVCMODEL_COMPONENT

versByComponent.sql (Versions by Component):

select component_id, count (component_id) as Comp 
from RMUSER.dngartifacts_db_artifact 
group by component_id order by Comp DESC;

versByConfigid.sql (Versions by Config ID):

-- Input parameter:  schema name

ACCEPT SCHEMA PROMPT 'Schema name:'

set linesize 999
set pagesize 999

select config_id, count (config_id) as configs 
from "&SCHEMA".REPOSITORY_VERSION 
group by config_id order by configs DESC;



DB2

ArtifactsPerComponent.sql (Number of Artifacts per component):

select component_id, count (distinct item_id) as Comp 
from dngartifacts.db_artifact 
group by component_id order by Comp DESC

-- Note: Query below is optional: If you require the component name you can use the Query below to dispaly the component name using the item_id returned from previous query above.

select NAME_COL from vvcmodel.component 
where item_id='an item_id from previous query';

ArtifactsPerFolder.sql (Number of Artifacts per Folder):

select folder, count(folder) from
(
select distinct A.item_id as art, F.ITEM_ID as folder from dngartifacts.db_artifact A 
INNER JOIN DNGFOLDERS.DB_FOLDER F ON F.ITEM_ID = A.PARENT_FOLDER_ITEM_ID
) group by folder order by count(folder) desc fetch first 100 rows only

-- Note: Queries below are optional: If you want to get from the folder ID to the title, something like this should work:

SELECT DISTINCT ITEM_ID, TITLE 
FROM DNGFOLDERS.DB_FOLDER F 
WHERE F.ITEM_ID = 'uuid from previous query'

This will get better info on where the folder is at. It only works on a single item id at a time

select distinct t1.item_id, t1.title, t3.name_col as project, t2.name_col as component from 
(select item_id, component_id, process_area_id, title 
from DNGFOLDERS.DB_FOLDER where item_id='item_id'
) t1 
inner join vvcmodel.component t2 on t2.item_id = t1.component_id 
inner join process.process_area t3 on t3.item_id = t1.process_area_id

ArtifactsPerModule.sql (Number of Artifacts per Module):

select module_item_id, count(distinct item_id) as count 
FROM dngartifacts.db_binding_container TBL_2A 
group by module_item_id order by count desc

-- Note: Queries below are optional: How would I convert module_item_id to an identifiable module, see below, if we have multiple item_id values, instead of " item_id = 'id' " you can use -- " item_id in ('id', 'id', 'id') "?

select distinct item_id,title 
from DNGARTIFACTS.DB_ARTIFACT 
where item_id = 'value of module_item_id'

This will get better info on where the module is at. It only works on a single module id at a time

select distinct t1.item_id, t1.id, t1.title, t3.name_col as project, t2.name_col as component from 
(select item_id, component_id, process_area_id, title, id 
from dngartifacts.db_artifact where item_id='module_item_id'
) t1 
inner join vvcmodel.component t2 on t2.item_id = t1.component_id 
inner join process.process_area t3 on t3.item_id = t1.process_area_id

ArtifactsPerProject_v7.sql(Number of Artifacts per Project):

SELECT COUNT(*), PA.NAME_COL FROM DNGARTIFACTS.DB_ARTIFACT A 
INNER JOIN PROCESS.PROCESS_AREA PA ON A.CONTEXT_ID = PA.ITEM_ID 
GROUP BY PA.NAME_COL order by count(*) desc;

Artifactstates.sql (Artifact States):

select item_id, jz_discriminator, count(item_id) from dngartifacts.db_artifact 
group by item_id, jz_discriminator having count(item_id) > 2 order by count(item_id)

Changesets per stream:

select S2.PARENT_STREAM_ITEM_ID, count(S2.PARENT_STREAM_ITEM_ID) 
from VVCMODEL.CHANGE_SET S2 
group by S2.PARENT_STREAM_ITEM_ID 
order by count(s2.PARENT_STREAM_ITEM_ID) desc

-- Note: Query below is optional: How would I convert S2.PARENT_STREAM_ITEM_ID to an identifiable stream?

select name from VVCMODEL.CONFIGURATION where item_id='value of parent_stream_id'

ComponentsPerProject.sql (Total number of Components per Project):

SELECT COUNT(*), PA.NAME_COL FROM VVCMODEL.COMPONENT C 
INNER JOIN PROCESS.PROCESS_AREA PA ON C.PROJECT_AREA_ID = PA.ITEM_ID 
GROUP BY PA.NAME_COL order by count(*) desc;

ContributionsPerGC.sql (Number of Contributions per GC):

select composite_id, count(composite_id) from repository.contributions 
group by composite_id order by count(composite_id) desc

linksPerArtifact.sql (Number of Links per artifact):

select artifact, count(artifact) from (select subject_item_item_id as artifact 
from dnglinks.db_link union all select object_item_item_id as artifact from dnglinks.db_link) 
group by artifact order by count(artifact) desc

Warning This query could run long so be sure to first test this in a non-production environment.

streamsPerComponent.sql (Number of Streams per component):

select component_item_id, count(component_item_id) 
from vvcmodel.configuration where type_col = 0 
group by component_item_id 
order by count(component_item_id) desc fetch first 100 rows only

tablespaceSizes.sql (Dispaly Table Space Sizes):

call get_dbsize_info(?, ?, ?, -1)

totalArtifacts_v6.sql (Total Artifacts):

SELECT COUNT(distinct item_id) FROM DNGARTIFACTS.DB_ARTIFACT A

totalArtifacts_v7.sql (Total Artifacts inclusive of states):

SELECT COUNT(*) FROM DNGARTIFACTS.DB_ARTIFACT A

TotalComponents.sql (Count of all Components):

SELECT COUNT(*) FROM VVCMODEL.COMPONENT C

versByComponent.sql (Versions by Component):

select component_id, count (component_id) as Comp 
from dngartifacts.db_artifact 
group by component_id order by Comp DESC

versByConfigid.sql (Versions by Config ID):

select config_id, count (config_id) as configs from REPOSITORY.VERSION 
group by config_id order by configs DESC

This topic: Deployment > WebHome > DeploymentMonitoring > UsefulSQlQueries
History: r6 - 2021-10-07 - 12:52:46 - WillChatham
 
This site is powered by the TWiki collaboration platformCopyright © by IBM and non-IBM contributing authors. All material on this collaboration platform is the property of the contributing authors.
Contributions are governed by our Terms of Use. Please read the following disclaimer.
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.