【发布时间】:2016-05-12 10:44:00
【问题描述】:
我必须在 mysql 中运行带索引和不带索引的相同查询。 我创建这样的索引:
create index index_1 on table_1(column_name);
create index index_2 on table_2(column_name);
我执行此操作,两次都得到 0 行影响的结果。这样可以吗?
因为当我执行我拥有的查询时(在我创建索引之后),我花费的时间与以前相同(没有索引)。
我有多个关于这个数据库的小查询,例如
SELECT DISTINCT customers.customer_id, customers.customer_name
FROM customers
INNER JOIN accounts ON customers.customer_id = accounts.customer_id
INNER JOIN transactions ON transactions.account_id = accounts.account_id
WHERE transactions.trn_date >= '2011/05/01'
AND transactions.trn_date <= '2011/05/31'
ORDER BY customers.customer_id
【问题讨论】:
-
信息太少。我们需要表定义、查询等。
-
索引是?
-
我们必须根据自己的判断在基表上创建 2 个索引,以减少查询的执行时间,但仍会略微增加新数据的加载时间
标签: mysql sql indexing database-indexes