Storing entities in DB: how attributes with static values are stored

Consider a template sensor:

template:
  - sensor:
      - name: my_sensor
        state: ...
        attributes:
          attr_1: xxxx
          attr_2: yyyy

Every change of the “sensor.my_sensor” is stored in DB.
Assume that attributes “attr_1” & “attr_2” are static.
A question: are these static values stored for every sensor’s change?

I have been using these static attributes for filtering purpose - like to keep info what a sensor is needed for.
And if DB stores same static values for these attributes for each sensor’s change - than it is a waste of DB volume. Probably DB should store only changing values.

@bdraco - you allowed me to tag you for this topic, so please find this question.

P.S. This is surely not only about template sensors; my question is for entities of any integration/domain since it is possible to manually add attributes via Customization.

Attributes are de-duplicated in the database. So if its always xxxx and yyyy are always the same it will store one copy. If xxxx changes to bbbb you get another copy in the database but only one.

When attributes change all the time it starts to get a problem because you end up storing every combination.

Thanks a lot for the reply!

Assume some entity has 3 static attributes (attr_a, attr_b, attr_c) & 1 dynamic attribute (attr_d).
What I see in DB in a “state_attributes” table - it has records for every combination.
Since here only 1 dynamic attribute - there are only records like:

attr_a = some static
attr_b = some static
attr_c = some static
attr_d = some dynamic

Assume there 100 records where only attr_d is different, but each record does contain same values for attr_a, attr_b, attr_c.
Means - static attributes may still occupy space if there is a dynamic attribute.