K
K
kupurim2019-01-29 14:17:43
Laravel
kupurim, 2019-01-29 14:17:43

Laravel simple request takes a long time to load, what's wrong?

Hello. I looked at the debug bar and saw that a request to receive 3 records is loaded in 4 seconds:

$feature = DB::table('news')
    ->where([
        ['published', '=', true],
        ['time', '>', DB::raw('NOW()')]
    ])
    ->limit(3)
    ->orderBy('time', 'asc')
    ->get();

I note that there are a lot of fields in this table (~ 50), but in this case you need to get about 20. List all in select? But then you have to add a new method for processing before output.
Laravel 5.3
Testing on Windows, no matter how sad it may sound.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kirill Arutyunov, 2019-01-29
@arutyunov

If you're on Windows, then it's possible. I also had a situation where the pages of a site on Windows (under OpenServer) loaded in 3–4 seconds precisely because of long queries to MySQL. Everything was ok in production.
For the sake of experiment, you can deploy it on a separate server somewhere and check it out (not in production). Yes, you have to work hard and deploy.
You can check your version and list the required fields in the request, but I think that's not the point.

K
Konstantin B., 2019-01-29
@Kostik_1993

The request itself is not super complex and does not even pull explicitly for a second. 50 records is practically nothing. Even 10 thousand for a normal request is a miserable amount. Dig towards the speed of MySQL itself or the connection between the application and the database. Database and site local?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question