Skip to content
Advertisement

How to improve eloquent nested foreach performance

How can I improve the performance of a query with the following characteristics (this is a simulation to exemplify):

JavaScript

In my real case, the foreach returns a lot of data with performance problems;

The Waiting (TTFB), that is, the time the browser is waiting for the first byte of a response, takes almost 27s

Advertisement

Answer

JavaScript
JavaScript

That will result in 3 queries and the output will be like:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement