It sounds like your initial connection is what is slow. It is counted as part of the query, as PDO does not distinquish it.
How is your .env set up in regards to the database ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Alright, i've been searching everywhere for a solution to this, but nothing i seems to improve my situation. I have a simple mysql query like this:
$this->session = Session::query()->select([
'key',
'data',
'last_accessed'
])->where('key', $this->sessionKey)->first();
VARCHAR(40)
The query takes about 1 second to execute. When i take the exact same query (copied using the laravel debugbar) and run it on the database (using DataGrip from the same machine laravel is on) the query barely takes 100ms to run.
Looking at the timeline from the debugbar is seems to be only the very first query that runs that is taking a long time. If i run a query like this DB::select("SELECT 1") right in front of the session query that query will take about 900ms while the session query all the sudden only takes only 200ms.
I am unable to post links on my first day after signing up but here is some screenshots with more information:
https:// imgur .com/a/rgRXphW (just remove the spaces ig)
(I also tried commenting out the additional pdo options without any change in speed.)
Please or to participate in this conversation.