Mysql index on view not working
问题 I created a view named 'myview' as below. create view myview as select 'a' source,col1,col2 from table_a union select source,col1,col2 from table_b ; table_a has an index on col1 , table_b has an index on source , col1 . When I query on myview as below, no index is used. select * from myview where source = a and col1 = 'xxx' ; How do I make the indexes work on this query? Create Code CREATE TABLE `table_a` ( `col1` VARCHAR(50) NULL DEFAULT NULL, `col2` VARCHAR(50) NULL DEFAULT NULL, INDEX