Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel join query taking too long

//if there is a users table with MILLIONS of records, to which you are joining.
//to speed up the query,
//You need to create an index WITH the column you are joining to.

//example query
$players_data = DB::table('players')
->select('users.*')
->leftjoin('users','players.email','=','users.email')
->get();

//now, create index by running this sql query in your database ->
ALTER TABLE users ADD INDEX user_email (email);

//now we have created an index ON THE Column (email), we are joining to.
//This will speed up the query time significantly.
 
PREVIOUS NEXT
Tagged: #laravel #join #query #long
ADD COMMENT
Topic
Name
9+1 =