skip to Main Content

How to further optimize the query after adding composite indexes? – Mysql

I have the following table: province_id owner_id game_id resource_production valid_from valid_until static_province_id auto incremented Integer integer integer integer timestamp timestamp integer I have two indexes: test_valid_from(game_id, owner_id, valid_from, valid_until) test_valid_until(game_id, owner_id, valid_until, valid_from) Every time the production of a province…

VIEW QUESTION

Improve Laravel Eloquent Query

I have this relation in my model... $this->hasMany('AppInventory')->where('status',1) ->whereNull('deleted_at') ->where(function($query){ $query ->where('count', '>=', 1) ->orWhere(function($aQuery){ $aQuery ->where('count', '=' , 0) ->whereHas('containers', function($bQuery){ $bQuery->whereIn('status', [0,1]); }); }); }) ->orderBy('updated_at','desc') ->with('address', 'cabin'); And Sql query generated are : select * from `inventories`…

VIEW QUESTION
Back To Top
Search