# List of attributes and tags currently in use

**URL:** <https://gramps.discourse.group/t/list-of-attributes-and-tags-currently-in-use/1779>\
**Category:** Help\
**Created:** [August 27, 2021, 8:59pm UTC](https://gramps.discourse.group/t/list-of-attributes-and-tags-currently-in-use/1779 "2021-08-27T20:59:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GeorgeWilmes](https://avatars.discourse-cdn.com/v4/letter/g/c57346/32.png) [@GeorgeWilmes](https://gramps.discourse.group/u/GeorgeWilmes)\
**Post date:** [August 27, 2021, 8:59pm UTC](https://gramps.discourse.group/t/list-of-attributes-and-tags-currently-in-use/1779/1 "2021-08-27T20:59:14Z")

</div>

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](https://gramps.discourse.group/t/extracting-constants-from-python-code/675/6).

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.

---

<div class="post-metadata">

**Author:** ![Mattkmmr](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/mattkmmr/32/410_2.png) [@Mattkmmr](https://gramps.discourse.group/u/Mattkmmr)\
**Post date:** [August 28, 2021, 1:52pm UTC](https://gramps.discourse.group/t/list-of-attributes-and-tags-currently-in-use/1779/2 "2021-08-28T13:52:46Z")

</div>

@GeorgeWilmes Your SELECT for attributes only lists **custom types** distinctly, since the [built-in types](https://github.com/gramps-project/gramps/blob/master/gramps/gen/lib/attrtype.py#L39) 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:

```auto
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;

```

---

<div class="post-metadata">

**Author:** ![GeorgeWilmes](https://avatars.discourse-cdn.com/v4/letter/g/c57346/32.png) [@GeorgeWilmes](https://gramps.discourse.group/u/GeorgeWilmes)\
**Post date:** [August 28, 2021, 2:55pm UTC](https://gramps.discourse.group/t/list-of-attributes-and-tags-currently-in-use/1779/3 "2021-08-28T14:55:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/free1/uploads/gramps/original/1X/2ac1e712b7adf612e31ca08a55419f4cf37c0158.png) [@system](https://gramps.discourse.group/u/system)\
**Post date:** [September 27, 2021, 2:56pm UTC](https://gramps.discourse.group/t/list-of-attributes-and-tags-currently-in-use/1779/4 "2021-09-27T14:56:33Z")

</div>

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