タグ

mysqlとMySQLに関するnipotanのブックマーク (87)

  • MySQL関連の書籍の決定版と言えば!

    Blog Search when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: ${entry.path} [in template "__entry.ftlh" at line 3, column 25] - Reached through: #include "__entry.ftlh" [in template "entry.ftlh" at

  • MySQL, Linux, and Thread Caching (by Jeremy Zawodny)

    Wow, it's been a busy week. I was totally swamped for several days dealing with the remember.yahoo.com MySQL servers and related stuff. And then I used a day or two to recover (sleep, shower, etc). Anyway, I made some interesting discoveries along the way. The most surprising one had to do with thread caching on Linux when you have a busy MySQL server--busy in a particular way, mind you. You see,

    nipotan
    nipotan 2005/12/28
    パフォチューネタ。by Jeremy D. Zawodny
  • order by rand() : blog.nomadscafe.jp

    order by rand() id:naoyaさんが書いている インデックスをかけてるテーブルでも、結局ランダムなので全件捜査してから値を返す。プライマリーキーに対して rand() する場合でも O(1) ではないのですよね。なんか回避する方法があったりするのかな order by rand()は最近知った方です。 通常ランダムで返す必要がある場合データベースではなくプログラム側で、2度SQLを発行してます。 my ($count) = $dbh->selectrow_array('select count(*) from table'); my $offset = int rand $count; my $ret = $dbh->selectrow_hashref('select * from table limit ?,1',{},$offset); これで対応してました。 やって

    nipotan
    nipotan 2005/11/18
    ORDER BY RAND() 論議。というか最近なんだか LIMIT にプレースホルダが使えないような希ガス…
  • MySQLのorder by rand() - jazzanovaのブログ

    インデックスをかけてるテーブルでも、結局ランダムなので全件捜査してから値を返す。プライマリーキーに対して rand() する場合でも O(1) ではないのですよね。なんか回避する方法があったりするのかな。 自分は良くorder by rand()を使ってます。 んで、id:naoya氏も懸念してるようにテーブルサイズが増大した時の動作とかその辺がorder by rand()だときついです。 追記 下記の方法はidに欠番があったりすると使い物になりません。 idに欠番がなく、idに数値を使ってる場合のみ有効です。悪しからず。 なので自分の場合は set @id = floor(rand()*n)+1; select id from entry where id = @id; ってな感じでやってます。 純粋にorder by rand()を使うより体感的にかなり高速だと思うけどどれくらい早く

    MySQLのorder by rand() - jazzanovaのブログ
    nipotan
    nipotan 2005/11/18
    ORDER BY RAND() LIMIT 1 な場合のもっと早い方法。ただ、id に DELETE によって欠番があると使えなかったりする罠。
  • MySQL の order by rand() - naoyaのはてなダイアリー

    MySQL のレコード取り出しの際に、ソートをランダムにできないものかと調べていたら、あった。 SELECT * FROM table ORDER BY RAND()こんな感じで。ソートを RAND にすれば良いという… そうそう、僕もこれは最近知ったんですが。Haropy でエントリーをランダムに取り出すのにも order by rand() を使ってます。Class::DBI::mysql に retrieve_random というメソッドがあって、ランダムに一見取り出すことができるという。これも中では order by rand() limit 1 をやってます。 ただ、この rand() はデータ量が大きいテーブルには使いづらいという罠。 mysql> explain select id from entry order by rand() limit 1 ?G *********

    MySQL の order by rand() - naoyaのはてなダイアリー
    nipotan
    nipotan 2005/11/18
    ORDER BY RAND() はデカいテーブルに不向きという話。EXPLAIN の末尾の \G が ?G に見えるのははてな仕様の SQL
  • MySQL destined for 'majority' market share

    nipotan
    nipotan 2005/10/20
    MySQL 急伸しシェア 44%
  • 現場指向のレプリケーション詳説

    この文書は、技術評論社刊『WEB+DB PRESS Vol.22』に執筆した記事を技術評論社の 許可を得てWWWで公開しているものです。 このWWW版は校正前の原稿を元にしている点、WWW公開後に必要があれば修正する点で、雑誌版の文章とは異なる部分があります。また、図表も雑誌版とは異なります。 予めご了承ください。 また、この文章が対象しているのはMySQL 4.0系なので、最新のリリース版と比べると説明不足な点などが多々あると思います。 レプリケーションの基をおさえるには、この文書はまだ有益だと思いますが、設定レベルの説明は最新のドキュメントを参照するようにしてください。

    nipotan
    nipotan 2005/09/24
    レプリケーション