optimization - Conditionally execute a subquery with MySQL -
i have view describes statistics of table, e.g.:
create table people ( playerid int not null auto_increment, name varchar(70), primarykey (playerid) ); create view personinfo_oranges (playerid, number_of_oranges) select playerid, count(orangeid) oranges ... ;
unfortunately, there's loads of data in tables person_info
looks @ (e.g. oranges) , view slow load. apparently known issues views. created table stores data of people (e.g. when become allergic oranges):
create table person_summary ( playerid int not null, number_of_oranges int, foreign key (playerid) references players(playerid) );
ideally create view searches person_summary
, and, if not found, looks in personinfo_oranges
. logic in model layer, how can in mysql?
Comments
Post a Comment