Skip to content

Performance Optimization in Home Assistant

Performance Database Advanced

A slow Home Assistant is frustrating. Dashboards that take forever to load, automations with delay, and a UI that stutters. Fortunately, most problems can be solved with the right configuration.


ProblemSymptomsCause
Slow UIDashboard loads slowlyLarge database, many entities
Sluggish historyGraphs take long timeSQLite bottleneck
High CPUConstant 80%+ loadToo many integrations polling
SD card wearCorrupt database, crashesToo many database writes
Slow startup5+ minutes to bootLarge database, many add-ons

Recorder is Home Assistant’s history engine. It writes everything by default - that’s often too much.

# configuration.yaml
recorder:
purge_keep_days: 7 # Keep only 7 days of history
commit_interval: 1 # Write to database every second
auto_purge: true # Automatic cleanup at 04:12
# configuration.yaml
recorder:
purge_keep_days: 7
exclude:
# Domains that generate A LOT of data
domains:
- automation # Automations don't need history
- updater # Update status
- camera # Camera states (images aren't stored)
# Specific entity patterns
entity_globs:
- sensor.sun_* # Sun sensors (update constantly)
- sensor.*_battery # Battery (changes slowly)
- binary_sensor.updater
# Individual entities
entities:
- sensor.date_time
- sensor.time
- sensor.uptime

Alternative approach - only save what you actually use:

# configuration.yaml
recorder:
purge_keep_days: 14
include:
domains:
- sensor # Sensors
- climate # Thermostats
- light # Lights (for energy tracking)
entities:
- person.brian # Presence
- binary_sensor.motion_living_room
exclude:
# Except these from included domains
entity_globs:
- sensor.*_battery
- sensor.*_linkquality
Entity TypeWhy
sensor.*_batteryChanges slowly
sensor.*_linkqualityZigbee signal - rarely needed
sensor.date_timeUpdates every second
binary_sensor.updaterUnnecessary
automation.*Trigger history is rarely useful
script.*Same as automation
*_last_seenZigbee last seen timestamps

For larger installations, MariaDB is recommended over SQLite.

SituationRecommendation
< 50 entitiesSQLite is fine
50-200 entitiesSQLite with optimization
200+ entitiesConsider MariaDB
Raspberry Pi + SD cardMariaDB on external SSD
Slow graphsMariaDB helps
  1. Go to Settings → Add-ons → Add-on Store

  2. Search “MariaDB” and install

  3. Configure add-on:

    databases:
    - homeassistant
    logins:
    - username: homeassistant
    password: "your-strong-password"
    rights:
    - username: homeassistant
    database: homeassistant
  4. Start add-on

  5. Update configuration.yaml:

    recorder:
    db_url: mysql://homeassistant:your-strong-password@core-mariadb/homeassistant?charset=utf8mb4
    purge_keep_days: 14
  6. Restart Home Assistant

For better performance, add options in add-on config:

{
"databases": ["homeassistant"],
"logins": [
{
"username": "homeassistant",
"password": "your-password"
}
],
"rights": [
{
"username": "homeassistant",
"database": "homeassistant"
}
],
"options": {
"innodb_buffer_pool_size": "256M",
"max_connections": 200
}
}
ParameterValueDescription
innodb_buffer_pool_size256M-512MRAM for database cache
max_connections200Concurrent connections

# configuration.yaml
logbook:
exclude:
domains:
- automation
- script
- group
entity_globs:
- sensor.*_battery
- sensor.*_linkquality
# configuration.yaml
history:
exclude:
domains:
- automation
- script
- updater
entity_globs:
- sensor.*_battery

Many integrations poll too often:

# configuration.yaml
# Example: Reduce polling for template sensors
sensor:
- platform: template
sensors:
daily_consumption:
friendly_name: "Daily Consumption"
value_template: "{{ states('sensor.energy') }}"
# Update only every 5 minutes
scan_interval: 300
  1. Go to Settings → Devices & Services

  2. Review all integrations

  3. Remove/disable those you don’t use

  4. Especially: Cloud-based integrations that poll


Reduce log level to save resources:

# configuration.yaml
logger:
default: warning # Only warnings and errors
logs:
homeassistant.core: warning
homeassistant.components.mqtt: warning
homeassistant.components.zha: warning
# Debug only for troubleshooting:
# homeassistant.components.automation: debug
# configuration.yaml
# Only if you don't use them:
discovery: # Auto discovery
zeroconf: # mDNS
ssdp: # UPnP discovery
RecommendationWhy
Use SSD10x faster than SD card
USB 3.0 adapterAvoid USB 2.0 bottleneck
Active coolingPi throttles at 80°C
Overclocking (careful)Can give 20%+ boost

# Automation to track database size
sensor:
- platform: sql
db_url: mysql://homeassistant:password@core-mariadb/homeassistant?charset=utf8mb4
queries:
- name: Database Size
query: "SELECT ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) as size FROM information_schema.TABLES WHERE table_schema = 'homeassistant'"
column: "size"
unit_of_measurement: "MB"
# configuration.yaml
sensor:
- platform: systemmonitor
resources:
- type: processor_use
- type: memory_use_percent
- type: disk_use_percent
arg: /
- type: load_1m
- type: load_5m

  • Check database size
  • Look for errors in logs
  • Verify automations are running
  • Clean up unused entities
  • Review recorder excludes
  • Update integrations

If the database has grown too large:

# Developer Tools → Services
service: recorder.purge
data:
keep_days: 3
repack: true

  • Reduce purge_keep_days to 7
  • Exclude automation, script domains
  • Exclude *_battery, *_linkquality entities
  • Reduce logger to warning
  • Review all entities - exclude unnecessary ones
  • Check polling intervals on integrations
  • Disable unused integrations
  • Add system monitoring
  • Migrate to MariaDB
  • Install on SSD (Raspberry Pi)
  • Fine-tune MariaDB parameters
  • Set up InfluxDB for long-term data

Ofte stillede spørgsmål

How many days of history should I keep?
7 days is fine for most people. If you use energy graphs or statistics, 14-30 days might make sense. Remember to exclude unnecessary entities - that's more important than the number of days.
Do I lose history when switching to MariaDB?
Yes, you start with an empty database. It's technically possible to migrate data, but it's complex and error-prone. Most people just start fresh.
Why is my Raspberry Pi slow?
SD cards are slow for database operations. Switch to an external SSD via USB 3.0, install MariaDB, and add active cooling. It makes a huge difference.
Can too many integrations make HA slow?
Yes, especially cloud-based integrations that poll often. Review your integrations and disable those you don't use. Also check if some integrations have unnecessarily high poll frequency.

Dashboard Design

Build fast, lightweight dashboards.

See guide →


Last updated: December 2025


Kommentarer