SQLite Forum

select * from t; -- but don't want virtual columns
Login
It's a form of [memoization][1]: given a deterministic expression for an oft-needed result, it's better to calculate it once and store it, then retrieved the cached copy as long as the inputs don't change, as opposed to repeatedly recalculating it.

When those inputs are also in SQLite, then stored virtual columns give you memoization at the DB layer, so you don't have to do it higher up in the application layer. Coupled with [application-defined SQLite functions][3], you can even do this for expressions that SQLite cannot calculate using only its built-in operators and functions — e.g. is this the record of a blue-chip customer — as long as the functions involved are all deterministic.

Additionally, it solves [one of the two hard problems in computer science][2].

Stored virtual columns are *very* good things.



[1]: https://en.wikipedia.org/wiki/Memoization
[2]: https://www.martinfowler.com/bliki/TwoHardThings.html
[3]: https://www.sqlite.org/appfunc.html