MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
harry890829
V2EX  ›  MySQL

mysql 在 sendingdata 上花费较多时间

  •  
  •   harry890829 · Aug 24, 2015 · 4847 views
    This topic created in 3949 days ago, the information mentioned may be changed or developed.

    现在情况是这样的有两个表 A/B ,其中 A 大概有 1k 多条记录, B 表中有 30k+条记录.
    当 select * from A left join b on xxxx=xxxx .....,执行这样的外联时,基本上耗时 30+秒,检查下来,在 sendingdata 上基本上就用了 30s 左右,其中, A/B 表都为 InnoDB 引擎,外键都做了索引,现在 innodb_buffer_pool_size 设置为 384m 。
    请问,这还需要设置那些地方,这种情况应该怎么处理啊……还是索引做的不对?


    那个……在发完提问后,我去重新查看了下索引,发现确实有索引没有做好……后来尝试了一下,应该是没有问题了……

    5 replies    2015-08-25 09:49:04 +08:00
    CheungKe
        1
    CheungKe  
       Aug 24, 2015
    加一个 and a.id = b.id
    CheungKe
        2
    CheungKe  
       Aug 24, 2015
    上面错了,应该是
    外键等于另外一张表的主键
    harry890829
        3
    harry890829  
    OP
       Aug 24, 2015
    @CheungKe 哦?这样会有对速度的提升么?
    CheungKe
        4
    CheungKe  
       Aug 24, 2015
    我理解错了,我们遇到的问题可能不一样。是 A 的 B 关联关系怎样,你要查询什么内容,如果内容比较多,是会比较慢。但是 30+肯定是不正常的
    harry890829
        5
    harry890829  
    OP
       Aug 25, 2015
    @CheungKe 嗯嗯,后来发现索引缺了两个……哎,太马虎啊,加上索引之后直接变成 0.9s ,吼吼
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5367 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 08:59 · PVG 16:59 · LAX 01:59 · JFK 04:59
    ♥ Do have faith in what you're doing.