That was fun - I hadn't done this before. Used a bunch of database views to refactor and optimize my solar power db. It was getting a little slow to aggregate per-second production data across months, so I switched the query to a view, and then slowly replaced the view with a union of the today data and a manually materialized view of the historical data.

Worked really well and now my rust code doesn't contain any complex SQL.

Don't tell @andy_pavlo but #databases are pretty cool sometimes.