How to implement Materialized View with MySQL?

前端 未结 4 1859
时光取名叫无心
时光取名叫无心 2021-02-02 12:38

How to implement Materialized Views?

If not, how can I implement Materialized View with MySQL?

Update:

Would the following work? This do

4条回答
  •  不知归路
    2021-02-02 13:37

    I maintain a project called Flexviews (http://github.com/greenlion/swanhart-tools) which adds incrementally refreshable materialized views to MySQL (aka fast refresh), even for views that use joins and aggregation. I've been working on this project for three years. It includes a change data capture utility to read the database logs. No triggers are used.

    It includes two refresh methods. The first is similar to your method, except a new version is built, and then RENAME TABLE is used to swap the new for the old. At no point is the view unavailable for querying, but 2x the space is used for a short time.

    The second method is true "fast refresh", it even has support for aggregation and joins.

    There is a blog post about it: http://www.mysqlperformanceblog.com/2011/04/04/flexviews-part-3-improving-query-performance-using-materialized-views/

    Flexviews is significantly more advanced than the FromDual example referenced by astander.

提交回复
热议问题