skip to Main Content

I have enabled mariadb general log. When I open my web app homepage in prod. env. I have like:

134777 Connect  root@58 as anonymous on google
        134777 Query    use `google`
        134777 Prepare  set names 'utf8' collate 'utf8'
        134777 Execute  set names 'utf8' collate 'utf8'
        134777 Close stmt   
        134777 Prepare  set session sql_mode='NO_ENGINE_SUBSTITUTION'
        134777 Execute  set session sql_mode='NO_ENGINE_SUBSTITUTION'
        134777 Close stmt   
        134777 Prepare  select * from `section_`
        134777 Execute  select * from `section_`
        134777 Close stmt   
        134777 Prepare  select `ego`.*, `hps`.`section_type_id` as `pivot_section_type_id`, `hps`.`it_id` as `pivot_it_id`, `hps`.`it_type_id` as `pivot_it_type_id`, `hps`.`order` as `pivot_order` from `ego` inner join `hps` on `ego`.`id` = `hps`.`it_id` where `hps`.`it_type_id` = ? and (`status` = ? and `publish_time` <= ?) and `hps`.`section_type_id` in (?, ?, ?, ?, ?) and `ego`.`deleted_at` is null order by `order` asc
        134777 Execute  select `ego`.*, `hps`.`section_type_id` as `pivot_section_type_id`, `hps`.`it_id` as `pivot_it_id`, `hps`.`it_type_id` as `pivot_it_type_id`, `hps`.`order` as `pivot_order` from `ego` inner join `hps` on `ego`.`id` = `hps`.`it_id` where `hps`.`it_type_id` = 1 and (`status` = 1 and `publish_time` <= '2018-07-30 23:46:17') and `hps`.`section_type_id` in (1, 2, 3, 4, 5) and `ego`.`deleted_at` is null order by `order` asc
        134777 Close stmt   
        134777 Prepare  select `cons`.*, `hps`.`section_type_id` as `pivot_section_type_id`, `hps`.`it_id` as `pivot_it_id`, `hps`.`it_type_id` as `pivot_it_type_id`, `hps`.`order` as `pivot_order` from `cons` inner join `hps` on `cons`.`id` = `hps`.`it_id` where `hps`.`it_type_id` = ? and (`status` = ? and `publish_time` <= ?) and `hps`.`section_type_id` in (?, ?, ?, ?, ?) and `cons`.`deleted_at` is null order by `order` asc
        134777 Execute  select `cons`.*, `hps`.`section_type_id` as `pivot_section_type_id`, `hps`.`it_id` as `pivot_it_id`, `hps`.`it_type_id` as `pivot_it_type_id`, `hps`.`order` as `pivot_order` from `cons` inner join `hps` on `cons`.`id` = `hps`.`it_id` where `hps`.`it_type_id` = 2 and (`status` = 1 and `publish_time` <= '2018-07-30 23:46:17') and `hps`.`section_type_id` in (1, 2, 3, 4, 5) and `cons`.`deleted_at` is null order by `order` asc
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `comm_mtvs`.`comment_id` as `pivot_comment_id`, `comm_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `comm_mtvs`.`value` as `pivot_value`, `comm_mtvs`.`id` as `pivot_id` from `mtnms` inner join `comm_mtvs` on `mtnms`.`id` = `comm_mtvs`.`mtnm_id` where `comm_mtvs`.`comment_id` in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `comm_mtvs`.`comment_id` as `pivot_comment_id`, `comm_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `comm_mtvs`.`value` as `pivot_value`, `comm_mtvs`.`id` as `pivot_id` from `mtnms` inner join `comm_mtvs` on `mtnms`.`id` = `comm_mtvs`.`mtnm_id` where `comm_mtvs`.`comment_id` in (1682, 1737, 1851, 2336, 2707, 2837, 4107, 4120, 5324, 6525, 6532, 6542, 6543, 6657, 8967, 10015, 13446, 13474, 13503, 14620, 15328, 16367, 16518, 16525, 16802, 16806, 58469, 58834, 58835, 58976, 58995, 62027) and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 15 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 25 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 21 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 14 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 18 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 16 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 26 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 13 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 49 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 15 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 48 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 510 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 19 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 14 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 511 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 138 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 510 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 12 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 10 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 14 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 16 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 13 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 13 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 15 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Prepare  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = ? and `mtnms`.`deleted_at` is null
        134777 Execute  select `mtnms`.*, `goea_mtvs`.`goea_id` as `pivot_goea_id`, `goea_mtvs`.`mtnm_id` as `pivot_mtnm_id`, `goea_mtvs`.`value` as `pivot_value` from `mtnms` inner join `goea_mtvs` on `mtnms`.`id` = `goea_mtvs`.`mtnm_id` where `goea_mtvs`.`goea_id` = 17 and `mtnms`.`deleted_at` is null
        134777 Close stmt   
        134777 Quit

As you can see, it has repeated queries over and over. The thing is I do not have this in my local environment. In my local, the same page executes 8 queries. I have absolutely no idea why this is happening. Do you know why it is and how to make it correct? Does it have something to do with mariadb configuration? Currently It is killing my processing units easily.

I must point out that I am using php laravel. The server’s is a CentOS 7. Web server is apache. Web app and db are separated over different addresses.

2

Answers


  1. The difference between your localhost and production might be due to the amount of rows in the database.

    Laravel lazy loads relationships by default, meaning that every time you iterate a collection of items over Eloquent and access a relationship, a new query will be executed under the hood.

    $users = AppUser::all();
    // Executes once: select * from users
    
    foreach ($users as $user) {
    
        foreach ($user->posts as $post) {
            // Executes for every user: select * from posts where user_id = $user->id
        }
    
    }
    

    To prevent it, You may want to take at look at eager loading relationships.

    $users = AppUser::with('posts')->all();
    // Executes once: select * from users
    // Executes once: select * from posts where user_id in ($users->pluck('id'))
    
    foreach ($users as $user) {
    
        foreach ($user->posts as $post) {
    
        }
    
    }
    

    https://laravel.com/docs/5.6/eloquent-relationships#eager-loading

    Login or Signup to reply.
  2. @symcbean
    @Chad K
    This is the snippet for fetching those records:

    $data = SectionType::with([
                   'categories' => function ($q) {
                       $q->orderBy('order', 'ASC');
                   },
                   'contents' => function ($q) {
                       $q->with('aod')->orderBy('order', 'ASC');
                   }
               ])->get();
    

    And I must point out that the amount of records is the same in both environments.

    @Jorge
    Thank. I we are already using eager loading. No difference.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search