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

ga46's avatar
Level 1

query performance

DB::table('usermetas')->where('status', 1)
                 ->select('browser', DB::raw('count(*) as total'))
                 ->groupBy('browser')
                 ->get();

now its query time 1.65 sec it's possible to decrease query performance?

0 likes
3 replies
rodrigo.pedra's avatar
  • How many records?
  • Which indices do you have in place?
  • What is the query plan?
  • What DBMS (MySQL, Postgres, ...)?

Out of my mind, I would try adding this index (assuming MySQL):

ALTER TABLE `usermetas` ADD INDEX `usermetas_index` (`status`, `browser`);

But adding the wrong index can make things worse.

rodrigo.pedra's avatar

@ga46 Have you tried the index above?

even on a low-end hardware 1.65 seconds seems slow.

Also please share the query plan (EXPLAIN SELECT ...), and if there are any indices in place

Please or to participate in this conversation.