History and logbook is painfully slow

I’ve seen many topics on this, but not many solutions. My DB is about 1.5GB, which isn’t that large.

I’m looking to find all “events” where a user left a zone. I assume I can write a sql query (I’m using mariadb). I can find all of the rows in the states table in 3 seconds. Why is logbook and history so slow then? It spins for minutes, if it ever returns results.

There are a number of factors that go into the performance of history and logbook. What are the specs of installation?

For me when I first started I had everything on the sdcard on my raspberry pi and it would take a really log time or too long for me to wait for either screen. After I moved my db to a usb drive it was significantly better. To improve it more I used the exclude option in recorder to not track unimportant sensors, vacuum cleaners, etc…whatever I didn’t need history on.

  db_url: !secret ha_db_url
      - automation
      - weblink
      - updater
      - media_player
      - camera
      - sensor
      - vacuum.roomba
      - sensor.google_travel_time