Laravel-datatables: have question in performace

Created on 11 Mar 2018  路  10Comments  路  Source: yajra/laravel-datatables

i have 100K record in users table how i can set limit for increase speed fetch data

return Datatables::of(DB::select('select * from users'))->make(true);

  • Operating System
  • PHP Version 7
  • Laravel Version 5.5
  • Laravel-Datatables Version
question

Most helpful comment

@vahidalvandi yes, pagination is automatically applied.

All 10 comments

ok how i can post limit start , end in query ? from yaja ajax ??

return Datatables::of(DB::select('select * from users limit :from,:to',['from'=>0 , 'to'=>15]))->make(true);

i need from , to in query ??

@vahidalvandi use something like:

return Datatables::of(DB::table('users'))->make(true);

DB::select() returns collection while
DB::table() returns a query builder.

do it automatically fetch query with paginate before return to Datatables ??

@vahidalvandi yes, pagination is automatically applied.

do this create query builder ?

invoice::where('invoice_type','sale_in')->select('id','user_id','invoice_amount')->orderBy('id', 'desc')->get()

because if i remove get() search and order in table not Work

You need to remove ->orderBy('id', 'desc')->get() for order to work and create a builder. Inspect the ajax request to debug further if it fails.

i need order by desc !!

Then sorting will not work since it's fixed on id desc.

thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

macnux picture macnux  路  3Comments

t0n1zz picture t0n1zz  路  3Comments

vipin733 picture vipin733  路  3Comments

alejandri picture alejandri  路  3Comments

ahmadbadpey picture ahmadbadpey  路  3Comments