这是我的查询:
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = "transactions"
这是花了多长时间:
Showing rows 0 - 29 ( 36 total, Query took 61.8934 sec)
我不是 dba,但这不正常,是吗?我是否应该期望查询 INFORMATION_SCHEMA 需要一分钟以上的时间?我在这里做错了什么吗?我是否需要添加索引或其他内容才能获得正常响应?
--- 编辑以解决问题
版本 5.5.30-30.2
该数据库由 HostGator 托管
EXPLAIN SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = "transactions"
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE COLUMNS ALL NULL TABLE_NAME NULL NULL NULL Using where; Open_frm_only; Scanned 1 database
显示创建表事务:
transactions CREATE TABLE `transactions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`accountId` int(11) NOT NULL DEFAULT '0',
`contractId` int(11) NOT NULL DEFAULT '0',
`insertionId` int(11) NOT NULL DEFAULT '0',
`aNetCIMProfileId` int(11) NOT NULL DEFAULT '0',
`paymentProfileId` int(11) NOT NULL DEFAULT '0',
`timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`wasSuccessful` tinyint(1) NOT NULL DEFAULT '0',
`amount` int(11) NOT NULL DEFAULT '0',
`resultText` varchar(255) NOT NULL,
`authNetTransactionId` bigint(20) NOT NULL DEFAULT '0',
`isChargedBack` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=41 DEFAULT CHARSET=latin1
SELECT Count( * )
FROM INFORMATION_SCHEMA.COLUMNS
[这也花了> 1分钟]
1303
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = "transactions"
AND TABLE_SCHEMA = 'mydbname'
相同的响应时间
SET global innodb_stats_on_metadata = 0;
#1227 - Access denied; you need (at least one of) the SUPER privilege(s) for this operation
(此数据库由 HostGator 托管)