Shelnutt2 / server

MariaDB server is a community developed fork of MySQL server. Started by core members of the original MySQL team, MariaDB actively works with outside developers to deliver the most featureful, stable, and sanely licensed open SQL server in the industry.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CacheTable View Algorithm

Shelnutt2 opened this issue · comments

Add a 4th view algorithm of type cachetable. The prescribed behavior would be for the results of a view to be stored in a table (possibly configurable on the engine) and cached for X period of time.

Currently Mariadb supports 3 types of view algorithms. The fastest method is merged, but has a limited scope of non-aggregate queries among other restrictions. The most support algorithm is temptable. This copies the results to a temp table before returning. This is similar to if the query was run live (which is what a view does in the general sense).

The initial idea would be to add this additional algorithm, which would store the results in a table, and read from the table until X time has passed expiring the "cachetable". At that point the next query to hit the view would cause a full refresh and update of the view.

There would need to be a lock on the refreshing of the table, and/or a fall back to temptable method while query was being run. Else it'd be possible for multiple inflight queries to be attempting to refresh this cache table.

This is an initial limited scope idea on longer term goals of materialized view.

Initial task list, this will expand as the work evolves.

  • Add cachetable to view_algorithm
  • Add CACHETABLE to lex
  • Add support in mariadb_fix_table
  • Add locking around refreshing of table
    • Fall back to temptable while refreshing cachetable
  • Use default engine for cachetable if no engine is given
    • Add new view option for setting engine table
  • Make cachetable name configurable