Mariadb不断重复查询

时间:2018-07-30 19:45:34

标签: php laravel apache mariadb

我已启用mariadb一般日志。当我在产品中打开我的Web应用程序主页时。环境我喜欢:

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

如您所见,它一遍又一遍地重复查询。问题是我在本地环境中没有此功能。在我本地,同一页面执行8个查询。我完全不知道为什么会这样。您知道为什么会这样以及如何使其正确吗?它与mariadb配置有关吗?目前,它很容易杀死我的处理单元。

我必须指出我正在使用php laravel。该服务器是CentOS7。Web服务器是apache。 Web应用程序和数据库通过不同的地址分开。

2 个答案:

答案 0 :(得分:0)

您的本地主机和生产版本之间的差异可能是由于数据库中的行数所致。

Laravel默认情况下懒惰加载关系,这意味着每次您在Eloquent上迭代项目集合并访问关系时,都会在后台执行新查询。

$users = App\User::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
    }

}

为防止这种情况,您可能想看看急切的加载关系。

$users = App\User::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

答案 1 :(得分:0)

@symcbean @乍得K 这是获取这些记录的代码段:

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

我必须指出,两种环境中的记录量是相同的。

@豪尔赫 谢谢。我已经在使用紧急加载了。没有不同。