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

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -