mysql - Does index work with view? -


assume have 2 tables:

table1(id, attribute1, attribute2) ,

table2(id, attribute1, attribute2) id primary key of 2 table

and have view:

create view myview select id, attribute1, attribute2 table1 union select id, attribute1, attribute2 table1 

can use advantage of index of primary key (in sql in general , mysql in case), when execute query following query ?

select * myview id = 100 

"can use advantage of index of primary key (in sql in general , mysql in case), when execute query following query?"

mysql consider using indexes have been defined on underlying tables. cannot create index on view. check link mysql restrictions on views further explanation.

using mysql explain on query using view show keys being considered under "possible_keys" column.

explain select * myview id = 100; 

Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -