Indexing a small table increases the query cost
Hi,
Running on 5.7.20, I have a query which runs often (every 10-15 seconds) and is giving me some weird results from some rather small tables ... data = 1400 rows, product 30, status = 70.
SELECT * FROM `data
JOIN status ON status_fk = status.id AND status.active
JOIN product on product_fk = product.id AND product.active
WHERE status.status IN ('a','b','c','d');
ALTER TABLE `product` ADD KEY `idx_active` (`active`);
ALTER TABLE `status` ADD KEY `idx_active` (`active`);
Query Cost: 3255
ALTER TABLE `product` DROP KEY `idx_active`;
ALTER TABLE `status` DROP KEY `idx_active`;
Query Cost: 242
Is it because we're indexing small datasets that the cost of the query jumps so high when there is an index?
Thanks.
Subject
Views
Written By
Posted
Indexing a small table increases the query cost
1288
February 28, 2018 04:52AM
547
February 28, 2018 08:50AM
648
February 28, 2018 11:24AM
517
February 28, 2018 11:30AM
490
February 28, 2018 12:58PM
726
March 01, 2018 03:15AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.