简体   繁体   中英

Does mysql View slow down the server?

I need to do some calculation each time when a user click "View Statistics" link. The calculation is based on a query. It's too complicated for me to figure out how to re-group the query result I posted a question about this before . Now I'm thinking to create a view of MERGE type first. Then, every time when need to show statistics, I can just query from this view. I have little knowledge about mysql. Not sure if this is the normal way to do the statistics calculation. When does the view get updated? Does it keeps updating whenever a new entry related to this View is posted? Or, it updates only when being queried? Should I delete the view every time after calculation?

You could use stored procedures as an alternative to views. This way you know that your data is freshly grabbed from your tables.

A view is not updated when data is inserted, it is simply a predefined query you can use.

If you have a need for complex calculations to create statistics, maybe create one or more triggers to help you to maintain a statistics table

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM