A
A
Andrei2582022-03-31 01:18:31
Laravel
Andrei258, 2022-03-31 01:18:31

Why is laravel so slow?

I have a PHP script that executes a database query 15,000 times.
The request takes only 1 second to complete. As soon as I translate the same request to laravel I get the result in 23 seconds. Is there a way to optimize this query and why is laravel so slow?
$mysqli->query("Select * From `users`");

Users::All();


Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyacheslav Plisko, 2022-03-31
@AmdY

Because you are requesting a huge amount of data at a time, which is then wrapped into objects. You should not do this on any project, load data in portions https://laravel.com/docs/master/eloquent#chunking-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question