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

TarikAli's avatar

mysql query take long time

i have table (languages) has only tow records and 4 columns when i run this query in laravel (select id, name, alies, dir from language where alies = 'ar' and status = '1' limit 1) it takes 34ms any reason for this long time

0 likes
8 replies
crnkovic's avatar

That's pretty slow, have you tried other db engines? Refresh x times? Leverage indexes? Slow hard drive? Using Eloquent, query builder, raw PDOs, mysqli, ...? So little details given.

NOMGUY's avatar

Why aren't you using Eloquent ORM for all this.. It would save your time and loading time too. Create a Model of language and after that in your controller it goes like:

$language = Language::where([
       'alies' => 'ar',
       'status' => 1,
])->limit(1)->get();
NOMGUY's avatar

yes you should @TarikSalah .. and i believe you have idea about models too. if not, feel free to ask anything about how to create and connect them.

TarikAli's avatar

when i run it in mysql it takes 0.0211 seconds

Tray2's avatar

There can be a lot of reasons as to why the query takes time. Some of them are already mentioned. What I would do it remove the limit = 1 from the statement since I doubt you have two alies that are the same and has status 1. However you need to consider that your query need to connect to the database, send the query through to the database that then needs to parse it and then run the query and lastly return the data to you. When running the query in MySQL I guess you mean from the mysql prompt you are already connected to the database.

TarikAli's avatar

the table have only tow records and no duoblicate

Please or to participate in this conversation.