CREATE TABLE orders (
id int(11) NOT NULL AUTO_INCREMENT,
created datetime NOT NULL,
payment_received datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
settled datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
dispatched datetime NOT NULL,
email varchar(100) NOT NULL,
first_name tinytext NOT NULL,
last_name tinytext NOT NULL,
address_line_1 tinytext NOT NULL,
address_line_2 tinytext NOT NULL,
address_line_3 tinytext NOT NULL,
address_city tinytext NOT NULL,
address_post_code tinytext NOT NULL,
address_country tinytext NOT NULL,
address_telephone tinytext NOT NULL,
address_mobile tinytext NOT NULL,
cancelled datetime NOT NULL,
cache_keyword text NOT NULL,
PRIMARY KEY (id),
KEY email (email),
KEY settled (settled),
KEY payment_received (payment_received,cancelled),
FULLTEXT KEY cache_keyword (cache_keyword)
);
The ANALYZE
for this query is predictably boring, but I do occasionally see it using the payment_received
index (presumably for the ORDER BY).
id | select_type | table | type | possible_keys | key | key_len | ref | rows | r_rows | filtered | r_filtered | Extra |
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | SIMPLE | o | ALL | NULL | NULL | NULL | NULL | 3163161 | 30.00 | 100.00 | 100.00 | Using where; Using filesort |