Long-term statistics - implementation details

I am really in love with the concept of more native support for long-term statistics! I was using integration with InfluxDB (and the add-on) to maintain statistics data so far. And I have an appetite to migrate completely in the future :wink:

I would like to ask the team about the implementation details. Can you share a context around the decision to implement the whole system for long-term statistics on your own and putting the data into SQLite? Do you follow some concepts from other libraries or tools? Is there a plan to provide bigger flexibility (like more aggregation functions and time shifts /i.e. to compare current energy usage with an average from the last month during a specific day in a week/)?

I was thinking about where it can go and the possibilities to use something existing to bring huge features set around long-term stats to HA users in relatively short time. Were you considering adoption of some components from good old Graphite (https://github.com/graphite-project)? It is written in Python, it is really efficient and stable (proven by many enterprises that were using it before the times of NewRelic or Datadog).
Of course I am biased here, because I have a big sentiment to Graphite from the times when I was its user and it was able to serve the whole monitoring for free from one bare metal server :grin: I have no clue about its licence details or how possible it would be to integrate its old codebase.

@emontnemery can you share how you envision the future of the statistics in HA?