List of attributes and tags currently in use

In case these may be useful to others, here are two queries to find out which attributes and tags you are currently using, and to what extent.

These queries use the SQLite export, and the one for attributes depends on the changes here.

select
from_type as “Object Type",
the_type1 as “Attribute Name",
count(*) as “Number of Occurrences”,
count(distinct value) as “Number of Distinct Values”
from attribute
join link on to_type = ‘attribute’ and to_handle = handle
group by 1, 2;

select
from_type as “Object Type",
name as “Tag”,
count(*) as “Number of Occurrences”
from tag
join link on to_type = ‘tag’ and to_handle = handle
group by 1, 2;

Additional queries could give more detail (such as which objects have those attributes or tags), but that’s better done within Gramps using custom filters.

3 Likes

@GeorgeWilmes Your SELECT for attributes only lists custom types distinctly, since the built-in types are stored in the_type0 with a value unlike zero and the_type1 is empty for them.

For a statistic for all attribute type (custom and built-in) use:

SELECT
from_type AS 'Object Type',
the_type0 AS 'Attribute Number',
the_type1 AS 'Custom Attribute Name',
COUNT(*) AS 'Number of Occurrences',
COUNT(DISTINCT value) AS 'Number of Distinct Values'
FROM attribute
JOIN link
ON to_type = 'attribute' AND to_handle = handle
GROUP BY 1, 2, 3;

Values for the_type1 should appear if you apply the changes that I linked to.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.