php - Multi-Threading in Laravel -


i running problem database calls slowing page load significantly. populating multiple charts elections data, , table contains around 1 million rows, , have query data multiple times in each methods inside getcharts() method.

i'am using this pass return data javascript.

these charts gets re-populated when click on data point. if click on point i.e ('democrat) reload page , call these methods again.

what asking wether possible in native php. server running php 5.2 on linode.

foreach(function in getchartsmethod){      start child thread process function.  }   join threads.  reload page.    public function getcharts(){         $this->get_cast_chart();         $this->get_party_chart();         $this->get_gender_chart();         $this->get_age_chart();         $this->get_race_chart();         $this->get_ballot_chart();         $this->get_county_chart();         $this->get_precinct_chart();         $this->get_congressional_district_chart();         $this->get_senate_district_chart();         $this->get_house_district_chart();         return view('elections.index');     } 

sample method

public function get_party_chart(){         $query = db::table($this->tablename)             ->select('party', db::raw('count(*) numvotes'))             ->groupby('party')             ->orderby('numvotes', 'asc');          if ($this->filterparameters != null){             $query = $query->where(key($this->filterparameters), $this->operator, current($this->filterparameters));         }         $chartdata = $query->get();         $chartdata = $this->prepare_data_for_chart($chartdata, 'party', 'numvotes');         javascript::put(['partychart' => $chartdata]);      } 

multithreading possible in php has been discussed on stackoverflow before: how can 1 use multi threading in php applications

however don't know how multithreading here. how data talking, kind of accuracy looking in charts? how many charts being shown? lot of solution come context.

if me, have background schedule pre-processing "huge" amounts of data more useful/usable on frontend. again useful/usable entirely depend on context. when there actual page request, need pass down processed data, versus actual "live" data.

again, again, entirely depend on context of application. perhaps need by-the-minute data, maybe don't.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -