Should I use view to make fixed conditions query?

Keywords´╝Ü mysql


If I want to get current day rows in a table,Which approach below is better than each other:

  1. Create a view and add where clause (e.g where create_time = curdate())
  2. Create a table, insert rows into it when some rows is inserted into relative table, and at every day 0am, clear all rows in the table by schedule event.

In most cases, I will only get a part of rows in the table but all.MySQL cannot add index to view, so the query performance of approach 2 may be better than approach 1's.

Actually, I want to know if there is cache for view query, by says, I create the view, and then I insert a row into the table which the view is relative to, will MySQL automaticly add the row to cache of the view for next query?