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?
- 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.
@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.