MySQL のチューニングについて考えてみた

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Favorite

    MySQL のチューニングについて考えてみた - Presentation Transcript

    1. MySQL のチューニングについて考えてみた tokuhirom
    2. MySQL は遅いか速いか
      • たぶん、速い。たいていの場合は。
      • でもときどき遅い。
    3. 遅い原因の見つけ方
      • Mysql の slow query log をみる
      • 表示に時間かかっているページをみつけて、そこのページの SQL を最適化してみたりする
    4. EXPLAIN
    5. EXPLAIN を制するものは MySQL を制す
    6. EXPLAIN の使い方
      • EXPLAIN SELECT COUNT(*) FROM foo;
      • id: 1
      • select_type: SIMPLE
      • table: NULL
      • type: NULL
      • possible_keys : NULL
      • key : NULL
      • key_len: NULL
      • ref: NULL
      • rows: NULL
      • Extra: Select tables optimized away
    7. EXPLAINの見方
      • インデックスがきいてるか、どうか。
      • possible_keys : NULL
      • key : NULL
    8. JOIN が遅い。
      • SELECT * FROM a INNER JOIN b (b.a_id = a) …
      • 4 つとか JOIN すると遅い。
    9. Using temporary;
      • テンポラリーテーブルを作る。
      • 遅い。
      • ユーザーが見てるページで、これがでてくるクエリを発行したらダメ。
    10. JOINを回避する方法
      • SELECT * FROM a INNER JOIN b (b.id=a.b_id);
      • SELECT * FROM a;
      • SELECT * FROM b WHERE id IN (?, ?, ?, ?);
      • に分割する。
    11. How to implement
      • my @rows =
      • Proj::Schema::Foo
      • ->fetch_with_cache_multi(@ids);
    12. get_multi の考え方
      • Memcached での考え方。
      • 複数キーで一気にひっぱってくる。
    13. fetch_with_cache_multi()
      • local $DBIx::Class::ResultSourceHandle::thaw_schema = $c->model_slave;
      • なんかやっとかないといけないらしい。
    14. fetch_with_cache_multi
      • get_multi する
      • とれなかった分は
        • IN でひっぱってくる。
        • set_multi する
      • まとめて返す。
    15. set_multi?
      • Cache::Memcached::Fast
    16. なぜ multi だと速いのか
      • select loop をまわします。。。
    17. That’s all.
      • Any questions?

    + tokuhiromtokuhirom, 2 years ago

    custom

    2340 views, 1 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 2340
      • 2340 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 1
    • Downloads 3
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Tags