加入大桌子越来越慢

时间:2017-10-20 07:21:37

标签: mysql database join innodb

我有2个innoDB表,一个有15166897个记录,另一个有700000个记录,有时当服务器上有加载时,基于这些表上的电子邮件地址的简单连接查询需要很长时间才能执行,有些时间会快速执行。但是,这两个表都已正确编入索引。

我们的数据库中有大约800个表,数据库大小为40GB。我们在AWS中运行t2.medium RDS实例,具有4GB的RAM,其中3GB分配给INNO DB BUFFER POOL。

我有以下问题,请在上面提出建议。

  1. 将大表分成小表是一个好主意,以便一个表上的记录变少,这是否会提高查询性能?
  2. 随着时间的推移,大表是否降低了查询的性能?
  3. 此RDS配置对于DB是否足够,或者是否需要改进配置?
  4. 修改 下面是我的表模式和索引定义:

    表1:总记录:7,00,000

        CREATE TABLE IF NOT EXISTS `tbl_contact_master` (
      `id` int(11) NOT NULL,
      `first_name` varchar(60) NOT NULL,
      `last_name` varchar(60) NOT NULL,
      `email_address` varchar(250) NOT NULL,
      `agency_name` varchar(150) NOT NULL,
      `state` varchar(30) NOT NULL,
      `zip_code` varchar(20) NOT NULL,
      `srch_zip` varchar(20) NOT NULL,
      `title` varchar(100) NOT NULL,
      `street` varchar(255) NOT NULL,
      `street2` varchar(255) NOT NULL,
      `city` varchar(30) NOT NULL,
      `country` varchar(30) NOT NULL,
      `phone` varchar(20) NOT NULL,
      `ext` varchar(20) NOT NULL,
      `fax` varchar(20) NOT NULL,
      `years_of_experience` varchar(50) DEFAULT NULL,
      `owner_manager` varchar(100) NOT NULL,
      `agency_type` varchar(100) NOT NULL,
      `agency_sales` varchar(100) NOT NULL,
      `agency_website` varchar(100) NOT NULL,
      `agency_host` varchar(100) NOT NULL,
      `agency_host_name` varchar(100) NOT NULL,
      `agency_affiliation` varchar(100) NOT NULL,
      `agent_sales` varchar(100) NOT NULL,
      `id_number_type` varchar(16) NOT NULL,
      `id_number` varchar(15) NOT NULL,
      `destination1` varchar(100) NOT NULL,
      `destination2` varchar(100) NOT NULL,
      `destination3` varchar(100) NOT NULL,
      `travel_type1` varchar(100) NOT NULL,
      `travel_type2` varchar(100) NOT NULL,
      `travel_type3` varchar(100) NOT NULL,
      `travel_type4` varchar(100) NOT NULL,
      `update_first_name` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_last_name` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_email_address` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_agency_name` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_state` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_zip_code` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_title` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_street` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_street2` datetime NOT NULL,
      `update_city` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_country` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_phone` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_ext` datetime NOT NULL,
      `update_fax` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_years_of_experience` datetime NOT NULL,
      `update_owner_manager` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_agency_type` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_agency_sales` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_agency_website` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_agency_host` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_agency_host_name` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_agency_affiliation` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_agent_sales` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_id_number_type` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_id_number` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_destination1` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_destination2` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_destination3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_travel_type1` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_travel_type2` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_travel_type3` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `update_travel_type4` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
      `create_status` tinyint(1) NOT NULL COMMENT '1 for website or 0 for add by csv',
      `created_date` datetime NOT NULL,
      `modified_date` datetime NOT NULL,
      `submited_date` datetime NOT NULL,
      `FirstPageDate` datetime NOT NULL,
      `is_retired` tinyint(1) NOT NULL COMMENT '0 = No, 1 = Yes',
      `update_is_retired` datetime NOT NULL,
      `ip_address` varchar(30) NOT NULL,
      `is_bademail` tinyint(1) NOT NULL,
      `update_is_bademail` datetime NOT NULL,
      `is_mice` tinyint(4) NOT NULL DEFAULT '0',
      `update_is_mice` datetime NOT NULL,
      `mice_company_disc` mediumint(5) unsigned NOT NULL,
      `update_mice_company_disc` datetime NOT NULL,
      `mice_meeting_region_plan` text NOT NULL,
      `update_mice_meeting_region_plan` datetime NOT NULL,
      `mice_ida` text NOT NULL,
      `update_mice_ida` datetime NOT NULL,
      `mice_associations` text NOT NULL,
      `update_mice_associations` datetime NOT NULL,
      `mice_meeting_regions` text NOT NULL,
      `update_mice_meeting_regions` datetime NOT NULL,
      `mice_average_attendance` mediumint(5) unsigned NOT NULL,
      `update_mice_average_attendance` datetime NOT NULL,
      `mice_annual_budget` mediumint(5) unsigned NOT NULL,
      `update_mice_annual_budget` datetime NOT NULL,
      `mice_facilities` text NOT NULL,
      `update_mice_facilities` datetime NOT NULL,
      `mice_annual_peak_rooms` mediumint(5) unsigned NOT NULL,
      `update_mice_annual_peak_rooms` datetime NOT NULL,
      `mice_nof_meetings` mediumint(5) unsigned NOT NULL,
      `update_mice_nof_meetings` datetime NOT NULL,
      `mice_job_resp_level` mediumint(5) unsigned NOT NULL,
      `update_mice_job_resp_level` datetime NOT NULL,
      `mice_event_resp_level` mediumint(5) unsigned NOT NULL,
      `update_mice_event_resp_level` datetime NOT NULL,
      `mice_is_planning` mediumint(5) unsigned NOT NULL,
      `update_mice_is_planning` datetime NOT NULL,
      `mice_experience` mediumint(5) unsigned NOT NULL,
      `update_mice_experience` datetime NOT NULL,
      `mice_primary_job` mediumint(5) unsigned NOT NULL,
      `update_mice_primary_job` datetime NOT NULL,
      `mice_company_size` mediumint(5) unsigned NOT NULL,
      `update_mice_company_size` datetime NOT NULL,
      `mice_primary_business` mediumint(5) unsigned NOT NULL,
      `update_mice_primary_business` datetime NOT NULL,
      `mice_primary_business_other` text NOT NULL,
      `mice_event_specialty` text NOT NULL,
      `update_mice_event_specialty` datetime NOT NULL,
      `mice_created_date` datetime NOT NULL,
      `mice_modified_date` datetime NOT NULL,
      `mice_submitted_date` datetime NOT NULL,
      `is_ta` tinyint(4) NOT NULL DEFAULT '0',
      `update_is_ta` datetime NOT NULL,
      `ta_created_date` datetime NOT NULL,
      `ta_modified_date` datetime NOT NULL,
      `ta_submitted_date` datetime NOT NULL,
      `is_mice_retired` tinyint(4) NOT NULL DEFAULT '0',
      `update_is_mice_retired` datetime NOT NULL,
      `not_ta_by` tinyint(2) NOT NULL COMMENT '0 for default, 1 for superadmin, 2 for contact',
      `update_not_ta_by` datetime NOT NULL,
      `not_mice_by` tinyint(2) NOT NULL COMMENT '0 for default, 1 for superadmin, 2 for contact',
      `update_not_mice_by` datetime NOT NULL
    ) ENGINE=InnoDB AUTO_INCREMENT=1096438 DEFAULT CHARSET=latin1;
    
    --
    -- Indexes for dumped tables
    --
    
    --
    -- Indexes for table `tbl_contact_master`
    --
    ALTER TABLE `tbl_contact_master`
      ADD PRIMARY KEY (`id`),
      ADD KEY `email_address` (`email_address`),
      ADD KEY `is_ta` (`is_ta`),
      ADD KEY `mice_created_date` (`mice_created_date`),
      ADD KEY `mice_modified_date` (`mice_modified_date`),
      ADD KEY `mice_submitted_date` (`mice_submitted_date`),
      ADD KEY `ta_created_date` (`ta_created_date`),
      ADD KEY `ta_modified_date` (`ta_modified_date`),
      ADD KEY `ta_submitted_date` (`ta_submitted_date`),
      ADD KEY `is_mice_retired` (`is_mice_retired`),
      ADD KEY `is_mice` (`is_mice`),
      ADD KEY `is_bademail` (`is_bademail`),
      ADD KEY `is_retired` (`is_retired`),
      ADD KEY `created_date` (`created_date`),
      ADD KEY `modified_date` (`modified_date`),
      ADD KEY `submited_date` (`submited_date`),
      ADD KEY `srch_zip` (`srch_zip`);
    

    表2:

    CREATE TABLE IF NOT EXISTS `tbl_master_partition` (
      `contact_id` int(10) unsigned NOT NULL,
      `inactive_group` varchar(200) DEFAULT NULL COMMENT '1=15,2=30,3=45,4=60',
      `inactive_from` datetime DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    
    --
    -- Indexes for dumped tables
    --
    
    --
    -- Indexes for table `tbl_master_partition`
    --
    ALTER TABLE `tbl_master_partition`
      ADD KEY `contact_id` (`contact_id`), ADD KEY `inactive_group` (`inactive_group`);
    

    表3:总记录:14400000

    CREATE TABLE IF NOT EXISTS `tbl_mandrill_email_mapping` (
      `id` bigint(20) NOT NULL,
      `log_id` int(11) NOT NULL,
      `batch_id` varchar(30) COLLATE utf8_unicode_ci NOT NULL,
      `m_id` varchar(50) COLLATE utf8_unicode_ci NOT NULL COMMENT 'unique mandrill message id',
      `s_id` varchar(100) COLLATE utf8_unicode_ci NOT NULL,
      `email` varchar(250) COLLATE utf8_unicode_ci NOT NULL,
      `open` int(11) NOT NULL DEFAULT '0',
      `click` int(11) NOT NULL DEFAULT '0',
      `send` int(11) NOT NULL DEFAULT '0',
      `hard_bounce` int(11) NOT NULL DEFAULT '0',
      `soft_bounce` int(11) NOT NULL DEFAULT '0',
      `reject` int(11) NOT NULL DEFAULT '0',
      `spam` int(11) NOT NULL DEFAULT '0',
      `unsub` int(11) NOT NULL DEFAULT '0'
    ) ENGINE=InnoDB AUTO_INCREMENT=15131814 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
    
    --
    -- Indexes for dumped tables
    --
    
    --
    -- Indexes for table `tbl_mandrill_email_mapping`
    --
    ALTER TABLE `tbl_mandrill_email_mapping`
      ADD PRIMARY KEY (`id`),
      ADD KEY `m_id` (`m_id`),
      ADD KEY `email` (`email`),
      ADD KEY `hard_bounce` (`hard_bounce`),
      ADD KEY `reject` (`reject`),
      ADD KEY `open` (`open`),
      ADD KEY `click` (`click`),
      ADD KEY `send` (`send`),
      ADD KEY `log_id` (`log_id`),
      ADD KEY `batch_id` (`batch_id`),
      ADD KEY `s_id` (`s_id`);
    

    缺少已添加的表

     CREATE TABLE IF NOT EXISTS `tbl_contact_173_230` (
          `id` int(11) NOT NULL,
          `contact_id` int(11) NOT NULL,
          `salutation` varchar(10) NOT NULL,
          `first_name` varchar(60) NOT NULL,
          `last_name` varchar(60) NOT NULL,
          `email_address` varchar(250) NOT NULL,
          `secondary_email_address` varchar(250) NOT NULL,
          `agency_name` varchar(150) NOT NULL,
          `state` varchar(30) NOT NULL,
          `zip_code` varchar(20) NOT NULL,
          `srch_zip` varchar(20) NOT NULL,
          `title` varchar(255) NOT NULL,
          `street` varchar(255) NOT NULL,
          `street2` varchar(255) NOT NULL,
          `city` varchar(30) NOT NULL,
          `country` varchar(30) NOT NULL,
          `phone` varchar(20) NOT NULL,
          `ext` varchar(20) NOT NULL,
          `fax` varchar(20) NOT NULL,
          `owner_manager` varchar(140) DEFAULT NULL,
          `years_of_experience` varchar(40) DEFAULT NULL,
          `agency_type` varchar(140) NOT NULL,
          `agency_sales` varchar(140) NOT NULL,
          `agency_website` varchar(140) NOT NULL,
          `agency_host` varchar(140) DEFAULT NULL,
          `agency_host_name` varchar(140) NOT NULL,
          `agency_affiliation` varchar(140) NOT NULL,
          `agent_sales` varchar(140) NOT NULL,
          `id_number_type` varchar(16) NOT NULL,
          `id_number` varchar(15) NOT NULL,
          `destination1` varchar(140) NOT NULL,
          `destination2` varchar(140) NOT NULL,
          `destination3` varchar(140) NOT NULL,
          `travel_type1` varchar(140) NOT NULL,
          `travel_type2` varchar(140) NOT NULL,
          `travel_type3` varchar(140) NOT NULL,
          `travel_type4` varchar(140) NOT NULL,
          `update_first_name` datetime NOT NULL,
          `update_last_name` datetime NOT NULL,
          `update_email_address` datetime NOT NULL,
          `update_agency_name` datetime NOT NULL,
          `update_state` datetime NOT NULL,
          `update_zip_code` datetime NOT NULL,
          `update_title` datetime NOT NULL,
          `update_street` datetime NOT NULL,
          `update_street2` datetime NOT NULL,
          `update_city` datetime NOT NULL,
          `update_country` datetime NOT NULL,
          `update_phone` datetime NOT NULL,
          `update_ext` datetime NOT NULL,
          `update_fax` datetime NOT NULL,
          `update_owner_manager` datetime NOT NULL,
          `update_years_of_experience` datetime NOT NULL,
          `update_agency_type` datetime NOT NULL,
          `update_agency_sales` datetime NOT NULL,
          `update_agency_website` datetime NOT NULL,
          `update_agency_host` datetime NOT NULL,
          `update_agency_host_name` datetime NOT NULL,
          `update_agency_affiliation` datetime NOT NULL,
          `update_agent_sales` datetime NOT NULL,
          `update_id_number_type` datetime NOT NULL,
          `update_id_number` datetime NOT NULL,
          `update_destination1` datetime NOT NULL,
          `update_destination2` datetime NOT NULL,
          `update_destination3` datetime NOT NULL,
          `update_travel_type1` datetime NOT NULL,
          `update_travel_type2` datetime NOT NULL,
          `update_travel_type3` datetime NOT NULL,
          `update_travel_type4` datetime NOT NULL,
          `opt_in_marketing` varchar(10) DEFAULT NULL,
          `travel_pro_user` varchar(10) DEFAULT NULL,
          `create_status` tinyint(1) NOT NULL,
          `crm_created_date` datetime NOT NULL,
          `crm_modified_date` datetime NOT NULL,
          `crm_submited_date` datetime NOT NULL,
          `crm_sync_date` datetime NOT NULL,
          `created_date` datetime NOT NULL,
          `modified_date` datetime NOT NULL,
          `submited_date` datetime NOT NULL,
          `offer_entry` datetime NOT NULL,
          `sync_date` datetime NOT NULL,
          `crm_status` tinyint(1) NOT NULL,
          `created_by` int(11) NOT NULL,
          `is_retired` tinyint(1) NOT NULL,
          `update_is_retired` datetime NOT NULL,
          `is_bademail` tinyint(1) NOT NULL,
          `update_is_bademail` datetime NOT NULL,
          `is_ta` tinyint(4) NOT NULL DEFAULT '0',
          `update_is_ta` datetime NOT NULL,
          `ta_created_date` datetime NOT NULL,
          `ta_modified_date` datetime NOT NULL,
          `ta_submitted_date` datetime NOT NULL,
          `mice_company_disc` text NOT NULL,
          `update_mice_company_disc` datetime NOT NULL,
          `mice_meeting_region_plan` text NOT NULL,
          `update_mice_meeting_region_plan` datetime NOT NULL,
          `mice_ida` text NOT NULL,
          `update_mice_ida` datetime NOT NULL,
          `mice_associations` text NOT NULL,
          `update_mice_associations` datetime NOT NULL,
          `mice_meeting_regions` text NOT NULL,
          `update_mice_meeting_regions` datetime NOT NULL,
          `mice_average_attendance` mediumint(5) unsigned NOT NULL,
          `update_mice_average_attendance` datetime NOT NULL,
          `mice_annual_budget` mediumint(5) unsigned NOT NULL,
          `update_mice_annual_budget` datetime NOT NULL,
          `mice_facilities` text NOT NULL,
          `update_mice_facilities` datetime NOT NULL,
          `mice_annual_peak_rooms` mediumint(5) unsigned NOT NULL,
          `update_mice_annual_peak_rooms` datetime NOT NULL,
          `mice_nof_meetings` mediumint(5) unsigned NOT NULL,
          `update_mice_nof_meetings` datetime NOT NULL,
          `mice_job_resp_level` mediumint(5) unsigned NOT NULL,
          `update_mice_job_resp_level` datetime NOT NULL,
          `mice_event_resp_level` mediumint(5) unsigned NOT NULL,
          `update_mice_event_resp_level` datetime NOT NULL,
          `mice_is_planning` mediumint(5) unsigned NOT NULL,
          `update_mice_is_planning` datetime NOT NULL,
          `mice_experience` mediumint(5) unsigned NOT NULL,
          `update_mice_experience` datetime NOT NULL,
          `mice_primary_job` mediumint(5) unsigned NOT NULL,
          `update_mice_primary_job` datetime NOT NULL,
          `mice_company_size` mediumint(5) unsigned NOT NULL,
          `update_mice_company_size` datetime NOT NULL,
          `mice_primary_business` mediumint(5) unsigned NOT NULL,
          `mice_primary_business_other` text NOT NULL,
          `update_mice_primary_business` datetime NOT NULL,
          `mice_event_specialty` text NOT NULL,
          `update_mice_event_specialty` datetime NOT NULL,
          `is_mice` tinyint(4) NOT NULL DEFAULT '0',
          `update_is_mice` datetime NOT NULL,
          `mice_created_date` datetime NOT NULL,
          `mice_modified_date` datetime NOT NULL,
          `mice_submitted_date` datetime NOT NULL,
          `is_mice_retired` tinyint(4) NOT NULL DEFAULT '0',
          `update_is_mice_retired` datetime NOT NULL,
          `recurring_opt_out` tinyint(1) unsigned NOT NULL DEFAULT '0',
          `custom_648` varchar(255) NOT NULL,
          `custom_649` varchar(255) NOT NULL,
          `custom_650` varchar(255) NOT NULL,
          `custom_717` varchar(255) NOT NULL,
          `custom_718` varchar(255) NOT NULL,
          `custom_719` varchar(255) NOT NULL,
          `custom_1369` varchar(255) NOT NULL,
          `custom_1454` varchar(255) NOT NULL,
          `custom_1455` varchar(255) NOT NULL,
          `custom_1469` varchar(255) NOT NULL
        ) ENGINE=InnoDB AUTO_INCREMENT=103603 DEFAULT CHARSET=latin1;
    
        --
        -- Indexes for table `tbl_contact_173_230`
        --
        ALTER TABLE `tbl_contact_173_230`
          ADD PRIMARY KEY (`id`), 
          ADD KEY `email_address` (`email_address`), 
          ADD KEY `contact_id` (`contact_id`), 
          ADD KEY `zip_code` (`zip_code`), 
          ADD KEY `srch_zip` (`srch_zip`), 
          ADD KEY `ta_submitted_date` (`ta_submitted_date`);
    

    下面的查询越来越慢,或者某些时候被卡住了。

    1

    SELECT  cm.id AS contact_id, mem.email, mem.open
        FROM  tbl_mandrill_email_mapping AS mem
        JOIN  tbl_contact_master AS cm  ON cm.email_address = mem.email
        WHERE  mem.log_id = XXXXX
    

    2

    SELECT  COUNT(crm.id) as total_record, SUM(UPPER(opt_in_marketing)='NO') as unsub_email_count,
            SUM(is_bademail=1) as invalid_email_count, COUNT(DISTINCT mp.`contact_id`) as inactive_email_count,
            SUM(is_retired=1
                  OR  is_mice_retired=1
               ) as retired_count
        FROM  (`tbl_contact_173_230` AS crm)
        INNER JOIN  `tbl_mandrill_email_mapping` as mem
            ON `mem`.`email` = `crm`.`email_address`
        LEFT JOIN`tbl_master_partition` AS mp
            ON `mp`.`contact_id` = `crm`.`contact_id`
           AND  crm.`ta_submitted_date` <  '2016-10-19'
           AND  FIND_IN_SET(5, mp.`inactive_group`) > 0
        WHERE  `crm`.`email_address` != '' AND`mem`.`log_id` = 'xxxx'
          AND  `mem`.`open` = 0
          AND  `mem`.`hard_bounce` = 0
          AND  `mem`.`reject` = 0
          AND  `mem`.`spam` = 0
        ORDER BY  `crm`.`id` ASC 
    

    编辑注意: 我注意到,当tbl_mandrill_email_mapping表上有非常频繁的更新/写入时,它通常会产生问题。这是一个处理电子邮件事件的日志表(发送,打开,点击,退回等..日志)。在我的情况下,一旦发送任何批量电子邮件(大约1,00,000封电子邮件),它会非常繁忙,并且它开始处理所有上述事件,有时这些事件非常频繁,在这种情况下,所有引用tbl_mandrill_email_mapping的查询卡住了。

    有任何处理这种情况的建议吗?我正在考虑读取副本,以便所有更新/插入将由不同的服务器处理并由不同的服务器读取句柄,它会工作吗?或者是否有任何处理这种情况的击球手解决方案?

    我愿意接受任何其他建议,请提出建议。

1 个答案:

答案 0 :(得分:1)

  1. 没有!不要把大桌子分成小桌子。你可能已经有“太多表”了。相反,专注于索引。我们来看SHOW CREATE TABLE和一些重要的查询。

  2. 增大的表会减慢无法充分利用索引的查询速度。好的指数不是这样。 (有例外情况;让我们看看你的问题。)

  3. 你只有4GB?而你正在将3GB buffer_pool加入其中?这不会为其他结构留下太多空间,也不会为其他应用留下太多空间。这可能导致交换,这对于性能来说是非常糟糕的。将innodb_buffer_pool_size删除至1500M。

  4. 增加'machine'大小(和buffer_pool)可能会有所帮助,也可能没有帮助。 buffer_pool是一个“缓存”,因此40GB并不完全相关。我们需要的是“工作集大小”,没有好的指标。

    你知道你是否受I / O约束吗?或CPU绑定?

    根据标题,我建议讨论查询。

    更多

    (现在看看Schema)

    更多索引 - &gt;加载速度慢。通常,一些好的索引值得额外加载时间。但重点是很少。不要索引标志;它们几乎永远不会有用。 (我假设你的is_*列是标志?)

    每个专栏更新后,您的应用真的关心吗?我看到的应用程序始于此类,但最终放弃了这个想法。

    CHARACTER SETs时请注意不要混用COLLATIONsJOINing。也就是说,FROM a JOIN b ON a.x = b.y x如果yCHARACTER SET不是相同 COLLATION INDEX(log_id, email, open) ,那么就不会使用索引。

    查询1将受益于此复合(和覆盖)索引:CREATE TABLE tbl_contact_173_230

    我没有看到{{1}} ??