I have a large (160 million rows, 50GB) table in MySQL 5.1 using MyISAM.
If I were to construct a view defined by a fairly complicated query, would a
SELECT on the view lock the underlying table?
Keep in mind that SELECTs and UPDATEs are mutually exclusive for MyISAM. That's is to say...
Using either SELECT or UPDATE automatically mitigate MyISAM locking behavior, anyway. So, the answer to your actual question would be yes since we are dealing with MyISAM.
I would recommend you use LOCK TABLES on the view. Why ?
According to the MySQL Documentation
Based on this, you should explicitly run LOCK TABLES on the view. The locks are performed on all the underlying tables then. That way, all the tables are locked as a group.
I'm making the assumption that you are hoping that it won't, but yes, the view will lock the underlying tables in the same way that the query inside the view would lock the tables.
However... this is a case where defining the view with the
Views in MySQL can be processed with one of two algorithms...
If you don't select an algorithm when you define a view, the optimizer will try to use
Presumably, though not stated, this could theoretically also result in not blocking other clients using the underlying table(s) (other than those using the view) for as long... but, by design, the views do lock the MyISAM tables against which they are defined.