问题
I have a table that contains 40 million data. I want to reduce the query time. is it possible to do it using views?. if yes, could you please explain how?.
回答1:
Yes, It is possible to reduce query time using view because it have clustered index assigned and they'll store temporary result that can speed up resulting queries.
回答2:
Well, the MySQL statement for creating a view is:
CREATE ALGORITHM = MERGE VIEW my_view AS
SELECT ...
Where the algorithm is one of MERGE, TEMPTABLE, or UNDEFINED.
However, as always the answer to how to increase performance is, "it depends". We really need more details on the table structure (columns and types), current indices, how often the table rows get updated, how often new rows get inserted, and what kind of data is stored in the table in order to make an educated guess on how to improve performance.
来源:https://stackoverflow.com/questions/23863546/mysql-view-is-faster-or-not-for-querying-from-db-that-containd-40-million-data