CREATE TABLE `fuga` ( `id` int(10) unsigned NOT NULL auto_increment, `category` int(11) NOT NULL, `name` varchar(40) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; のようなテーブルを用意して、0〜9999までのランダムなcategoryで適当なnameを含むデータを30万件ほど突っ込んでみる。1つのcategoryあたり30件くらい取れる計算。 普通にwhereでcategoryを指定して取ると結構遅い。はかってみる。 #!/usr/bin/perl use strict; use warnings; use DBI; use Benchmark 'timethis'; my $dbh =