Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

X chris X's avatar

query is fast | loading results in page VERY slow

Newish to Laravel.

Simple query: $participants = DB::table('users') ->where('course_serial', $serial) ->where('t_status', '<>', '') ->orderBy('Id', 'asc') ->get(['Id','first_name','last_name','email', 'phone','serial', 't_status']);

Query takes "0.010648012161255" - yet loading the 22 results the query returns in a blade view with @foreach takes +30 seconds ?!?

The entire Laravel application is very responsive and webpages load fast from a competent AWS server.

Any suggestions are greatly appreciated.

0 likes
11 replies
Sinnbeck's avatar

Can you replicate it locally? Can you show the code that is slow? If I understand you correctly, it is just 1 page that is slow? Can we see the page that is slow or is it behind a login?

X chris X's avatar

@Sinnbeck behind login & correct the page generating view of the results is painfully slow :)

X chris X's avatar

@Sinnbeck hmmm ... VS Coding into AWS directly; I moved from local dev straight into the instance.

The App is working really well with other queries and paginates reasonably fast (+800 records) excerpt this instance of code.

I really like Laravel despite my lack of understanding and this code instance is the ONLY really weird and outlying experience per se.

Nakov's avatar

And the page where you are trying to load those results is completely empty? Just a list with those results.. or you have some scripts loading and other stuff?

The network tab says that the page took 30 seconds to load? That's unreal.

X chris X's avatar

@Nakov simple table showing @foreeach results

        @foreach ($students as $student)

              <tr>
                <td>{{$ID}}</td>
                <td> {{$student->first_name}}</td>
                <td>{{$student->last_name}} </td>
                <td>{{$student->email}}</td>
                <td>{{$student->phone}}</td>
                <td>{{$student->serial}}</td>
                
            </tr>
            
        @endforeach

Queued at 0 Started at 5.33 ms

Queuing 5.33 ms

Stalled 2.62 ms Request sent 0.41 ms Waiting (TTFB) 31.62 ms Content Download 4.51 ms

Nakov's avatar

@X chris X

31.62 ms is not seconds, it is miliseconds.

X chris X's avatar

@Nakov correct - yet the page loads the view of the results in +30 seconds.

Nakov's avatar
Nakov
Best Answer
Level 73

@X chris X and yet again, that might be because of some scripts that you have. Just create simple blade page without extending any of your styling/scripts and make sure that just drawing the table with the results really takes that slow..

1 like
X chris X's avatar

@Nakov Yes - oh, damn, the innocuous style tag ... too bad there are no emojis in this form to see my head hanging in shame.

Thank you Sir.

Please or to participate in this conversation.