智能刊登gaussdb 慢sql top 10
2.解决方案
1.这种全表扫描,没有走索引,慢日志记录100多秒,是否可以改成 where id> 1000000,2. 查看是否要新建索引
3.原sql
SELECT COUNT(*) AS count_star, COUNT(DISTINCT `CustomerId`) AS ndv_1, COUNT(DISTINCT `SiteCode`) AS ndv_2, COUNT(DISTINCT `ProductId`) AS ndv_3, COUNT(DISTINCT `Sku`) AS ndv_4
, COUNT(DISTINCT `CategoryId`) AS ndv_5, COUNT(DISTINCT `MarketId`) AS ndv_6, COUNT(DISTINCT `Id`) AS ndv_7, COUNT(DISTINCT `FirstCategoryId`) AS ndv_8, coalesce(SUM(`CustomerId` = 1), 0) AS matched_9 , coalesce(SUM(`MarketId` = 57), 0) AS matched_10 FROM `irobotbox_marketpublish`.`P_Market_Product` LIMIT 1000000