Get data faster from databasse My site having a more than 1.5 million records and my question is the how may i fetch record fast.

i am spending so much time to find the way for it finally find out the one way which is to apply the indexing on the field. also try to apply on that it's better result than before.

but still it taking to much time to getting data from the database can any one tell me other technique or trick which i applied on that so it give me much better performance. and my site is built in laravel 4.2.

You can see also my query like below

     $result = DB::table('bussiness')
                -&gt;select(array('bussiness.*', DB::raw('COUNT(complaintreport.id) as reported')))
                -&gt;where('bussiness.is_approved', 1)
                -&gt;where('bussiness.status', 1)
                -&gt;where(function($sql) use ($data) {
                    $sql-&gt;where('bussiness.bussiness_name', 'like', '%' . Str::upper($data['searchstring']) . '%');
                    $sql-&gt;orWhere('bussiness.trading_name', 'like', '%' . Str::upper($data['searchstring']) . '%');
                })
                -&gt;leftjoin('complaintreport', 'complaintreport.bussiness_id', '=', 'bussiness.id')
                -&gt;groupby('bussiness.id')
                -&gt;get();


Thanks in advance.
What you have is a full table scan with no way to speed it up.

Look into FULLTEXT(bussiness_name, trading_name) indexing as a much faster way to search for words.  You would need MATCH (bussiness_name, trading_name) AGAINST("$data['searchstring']" IN BOOLEAN MODE).

If status is rarely 1 and is_approved is rarely 1, then this would help: INDEX(status, is_approved).

You should also protect yourself from SQL injection by escaping the searchstring.