Because my data load is very slow?

Because my data load is very slow?

emmanuel921218emmanuel921218 Posts: 11Questions: 4Answers: 0
edited March 2020 in Free community support

I have the problem that my table when loading data for example 11,000 data is stuck or stunned for a moment makes it very slow.

This is how I run DataTable, there really are more columns but I have removed some.

var genealogytable = $('#genealogy').DataTable({
    destroy: true,
    ajax: { 
       url: "reloadTab/"+idsponsor+"/"+period+"/"+typee,
       type: "GET", 
       datatype: "json" 
     },
    columns: [ 
        {
            data: null,
            className: "center",
            defaultContent: '<a href="javascript:void(0)" onclick="addRowGen(this.parentNode.parentNode.id)">' + 
                '<img src="{{ asset('img/add2.png')}}" width="30px"/>' + 
            '</a>'
        },

        {
            'targets': 0,
            'searchable':false,
            'orderable':false,
            'className': 'dt-body-center',
            'render': function (data, type, row){
                return '<td> <p><label> <input type="checkbox" id="emailGenealog[]" name="email[]" class="check_mailGenealogy" onclick="mailRowGen(this.parentNode.parentNode.parentNode.parentNode.id)" name="" value="'+row.email+'" /><span></span></label></p> </td>';
            }
        },
        {data: 'Line'},
        {data: 'Level'},
        {data: 'associateid'},
        {data: 'associatename'},

});

And this is the controller where I run a Store Procedure to get the data,

public function reloadTab(Request $request, $idsponsor, $period, $typee){
    $idsponsor = $request->idsponsor;
    $period = $request->period;
    $type = $request->typee;

    ini_set('memory_limit', '-1');
    $conection = \DB::connection('sqlsrvgenealogy');
        $response = $conection->select('EXEC Sp_TreePerId ?,?,?', array($idsponsor, $period, $type));
    \DB::disconnect('sqlsrvgenealogy');
    $data = [
        'data' => $response,
    ];
    return \Response::json($data);

}

and finally the route

Route::get('reloadTab/{idsponsor}/{period}/{typee}', 'Genealogy\genealogyController@reloadTab');

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    This section of the FAQ should help, it discusses various techniques to improve performance,

    Cheers,

    Colin

This discussion has been closed.