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

madprabh's avatar

HTTP request - What is more efficient? Need advice.

Hey, Laracasts community!

I need some advice on this situation.

So I have a HTTP request that takes like 12-15 seconds to bring back data from the server and put it up in the HTML page.

Should I break up the request into multiple HTTP requests and bring data in chunks to improve this performance?

Best, Madhu

0 likes
5 replies
Snapey's avatar

its unlikely to be the http request

Install laravel debugbar and check the number of queries

Dalma's avatar

In general a 12 to 15 delay in rendering a web page will not be well received unless you provide some form of visual progress bar or other type of distraction.

jlrdw's avatar

unless you provide some form of visual progress bar or other type of distraction

There you go, put up one of those little wheel things that go round and round. This part I am joking.

Cronix's avatar

I have tens of millions of rows in a real estate app containing property data for most of the larger markets in the US. Some pages have more than 80 queries to get all of the data for a single property. It takes less than 700ms to do that. Your problem is most likely an unoptimized database. Missing indexes on fields that are used in where statements, and order by statements, or foreign key fields (user_id in profile table type stuff), etc.

There is a lot to know about db optimization, which laravel can't help you with (beyond you setting up the proper indexes in your migrations). You can't just have the default id field be indexed.

So, I second @snapey when he suggests to install the laravel debugbar, and enable the explain function for queries, which will give you more info on why it takes so long: https://github.com/barryvdh/laravel-debugbar/blob/master/config/debugbar.php#L144

I'd highly suggest watching this tutorial on query optimization via indexing. He uses laravel and shows in realtime the difference as he adds the indexes, and explains why they are necessary and also drawbacks in certain scenarios. https://serversforhackers.com/laravel-perf/mysql-indexing-one

Please or to participate in this conversation.