Skip to content

Serverside Render - So Slow Performance #2482

@tcagkansokmen

Description

@tcagkansokmen

`I am using serverside render. And my code is below.

There's only 2500 products on list.
And it takes 30 seconds to render. If I remove "Datatables::of($products)->make(true);" line, it returns on 20ms.

What's wrong with it?
What should I do?

    $parameters = $this->request->query();
    $firm_id = $this->request->user()->firm_id;

    $products = Product::where('firm_id', $firm_id)
    ->with(['category', 'inventory' => function($q){
        $q->where('cost', '>', 0);
    }])
    ->orderBy('id', 'desc');
    if(isset($parameters['category_id'])){
        $products = $products->where('product_category_id', $parameters['category_id']);
    }

    $products = $products->get();

    $products = ProductResource::collection($products);

    return Datatables::of($products)->make(true);`

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions