Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

N対1 レプリケーション + Optimizer Hint

1,226 views

Published on

MySQL Casual Talks vol.8

Published in: Technology
  • Be the first to comment

  • Be the first to like this

N対1 レプリケーション + Optimizer Hint

  1. 1. N対1 レプリケーション + Optimizer Hint 2015/11/20 MySQL Casual Talks vol.8 do_aki
  2. 2. @do_aki @do_aki http://do-aki.net/
  3. 3. Master A Master C Slave A+B+C N:1 Replication Master B
  4. 4. Master A Master C Slave A+B+C N:1 Replication Master B
  5. 5. Master A Master C Slave A+B+C N:1 Replication Master B
  6. 6. Master A Master C Slave A+B+C N:1 Replication Master B
  7. 7. Master A Master C Slave A+B+C N:1 Replication Master B
  8. 8. Master A Master C Slave A+B+C N:1 Replication Master B
  9. 9. N1Repl
  10. 10. 近況報告
  11. 11. 動いてます 無停止稼働1年 通算4年
  12. 12. Multi-source Replication on MySQL 5.7 GA https://dev.mysql.com/doc/refman/5.7/en/replication-multi-source.html
  13. 13. Master A Master C Slave A+B+C Multi-source Replication Master B
  14. 14. Master A Master C Slave A+B+C Multi-source Replication Master B channel1 channel2 channel3
  15. 15. Master A Master C Slave A+B+C Multi-source Replication Master B channel1 channel2 channel3 GTID 不要!
  16. 16. Use The Multi-source Replication, Luke.
  17. 17. /****************** * * “いつもの” * ここまで * *******************/
  18. 18. 突然ですが
  19. 19. query cache
  20. 20. • SET query_cache_type = 0; // OFF • SET query_cache_type = 1; // ON • SET query_cache_type = 2; // DEMAND • SELECT SQL_CACHE * FROM xxx …… • SELECT SQL_NO_CACHE * FROM xxx ……
  21. 21. ステートメント単位で制御でき るといえば
  22. 22. Optimizer Hints (>=5.7) • optimizer_switch => Global/Session • Optimizer Hints => Statement • SELECT /*+ HINT(target)*/ * FROM … • INSERT … SELECT /*+ HINT */ … • UPDATE /*+ HINT */ …
  23. 23. Optimizer Hints Available BKA/NO_BKA  BNL/NO_BNL  MRR/NO_MRR  NO_ICP  NO_RANGE_OPTIMIZATION  蝉SEMIJOIN / NO_SEMIJOIN  SUBQUERY  QB_NAME  MAX_EXECUTION_TIME
  24. 24. SELECT SQL_NO_CACHE /*+ HINT */ * FROM … SELECT /*+ HINT */ SQL_NO_CACHE * FROM … SELECT /*+ HINT */ /*!40001 SQL_CACHE */ FROM … SELECT /*+ HINT *//*!40001 SQL_CACHE */ FROM …
  25. 25. SELECT SQL_NO_CACHE /*+ HINT */ * FROM … SELECT /*+ HINT */ SQL_NO_CACHE * FROM … SELECT /*+ HINT */ /*!40001 SQL_CACHE */ FROM … SELECT /*+ HINT *//*!40001 SQL_CACHE */ FROM … NG: Hint が SELECT の直後でないので効かない OK OK NG: スラッシュが連続するためパースエラー
  26. 26. query cache からすると別クエリ SELECT /*+ MAX_EXECUTION_TIME(1000) */ SQL_CACHE * FROM table; SELECT /*+ MAX_EXECUTION_TIME(2000) */ SQL_CACHE * FROM table;
  27. 27. MAX_EXECUTION_TIME • クエリ実行にタイムアウトを設定 • 5.7.8 より前は MAX_STATEMENT_TIME mysql> SELECT /*+ MAX_EXECUTION_TIME(1000) */ * FROM big_table; ERROR 3024 (HY000): Query execution was interrupted, maximum statement execution time exceeded
  28. 28. MySQL5.7 じゃないけど MAX_EXECUTION_TIME を使いたい人に
  29. 29. • N:1 Replication 今も動いてるよ • Optimizer Hint 便利だね • MySQL5.7 なくても、クエリ単位でタイ ムアウト設定できるよ
  30. 30. おしまい

×