简体   繁体   中英

How to optimize the most frequent MySQL SELECT query

I have a MySQL table with millions of records, and there are hundreds of records inserted into the table every day.

In the front-end, it displays the most recent 100 records using the query:

SELECT * FROM 
table_a 
ORDER BY creation_time DESC 
LIMIT 100

Every time a user visits the page, it will scan through the large table and perform the sorting. The procedure looks very resources consuming.

I find that there is a VIEW in MySQL. Does it help to optimize the performance if I create a view to store the results? Is the view synchronized with the original table? Or any other means to boost the query performance?

Thanks!

You can try following things to speed up your query:

1. Select only required column(s) instead of all (*) in SELECT Query.
2. Create Indexes on creation_time.

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