IN句が5000レコードを超えるこのクエリがなぜ遅すぎるのかを説明できる人がいますか?何人かが私になぜこれが質問であると伝えることができますか?
表のstrucuture
CREATE TABLE IF NOT EXISTS `wp_transactions_log` (
`sync_sequence` bigint(20) unsigned NOT NULL COMMENT 'the sequence number of the sync process/operation that this transaction belong to ',
`objectid` varchar(100) NOT NULL COMMENT 'the entity/record id',
`wp_id` bigint(20) unsigned NOT NULL,
`table_name` varchar(100) NOT NULL COMMENT 'the target wordpress table name this transaction occured/fail for some reason',
`logical_table_name` varchar(100) NOT NULL,
`operation` varchar(20) NOT NULL COMMENT 'inser/update/delete',
`status` varchar(20) NOT NULL COMMENT 'status of the transaction: success,fail',
`fail_count` int(10) unsigned NOT NULL COMMENT 'how many this transaction failed',
`fail_description` text NOT NULL COMMENT 'a description of the failure',
`createdon` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`sync_sequence`,`objectid`,`table_name`,`operation`,`wp_id`),
KEY `objectid` (`objectid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
この表は5kのレコードが含まれています。
クエリ:
SELECT wp_id,objectId FROM wp_transactions_log WHERE `operation` = "insert" AND `wp_id` != 0 AND `status` != "ignore" AND `table_name` ='itg_wpclass_dates' AND objectId IN (... 5k record)
も、このクエリは同じです:
SELECT wp_id,objectId FROM wp_transactions_log WHERE objectId IN (5k record)
注:のIN句のすべてのパラメータは、表の行に同じそのものです。 私は15秒以上かかることを意味します。
可能な複製http://stackoverflow.com/questions/4226035/why-does-a-query-slow-down-drastically-if-in-the-where-clause-a-constant-is-repl –
遅すぎると秒が何秒ですか?私は何年も前に同様のテストを行い、 'IN'節で10Kを使用し、' 0.04'秒で実行しました。 http://stackoverflow.com/a/7818697/153723私は問題がテーブルではないと信じています。 – Ergec
いいえ15秒以上です –