Mysql VIEWS vs. PHP query

前端 未结 5 1019
温柔的废话
温柔的废话 2021-02-12 11:16

I am working on a web application which involves create list of Restaurants in various lists like \"Joe\'s must visit places\". Now for each Restaurant and list, I have display

5条回答
  •  我寻月下人不归
    2021-02-12 12:02

    Using views adds a level of abstraction : you may later change the structure of your tables, and you will not have to change the code that displays the information about the lists, because you will still be querying the view (the view definition may change, though).

    The main difference is that views are updated after each insertion, such that the data is "ready" whenever you query the view, whereas using your custom query will have MySQL compute everything each time (there is some caching, of course).

    The bottom line is that if your lists are updated less frenquently than they are viewed, you will see some gains in performance in using views.

提交回复
热议问题