MySQL View containing UNION does not optimize well…In other words SLOW!
问题 I have a view containing a UNION ALL. For example: CRATE VIEW myView as (SELECT col1, col2, col3 FROM tab1) UNION ALL (SELECT col1, col2, col3 FROM tab2) These are large tables containing 10s of millions of rows each. If I write: SELECT * FROM myView LIMIT 1; instead of being immediate, it basically never returns as do other queries written against this view. If I use the LIMIT in a query against the individual underlying tables, it is immediate. I have indexes on the underlying tables. It