MySql技术之"虚拟表增加索引"

一、虚拟表增加索引

创建虚拟表,并且增加SKU索引:INDEX idx_sku (sku)

CREATE TEMPORARY TABLE t_sku_analy_temp (
    sku VARCHAR(225) PRIMARY KEY,
    sell_price DECIMAL(10, 2),
    profit DECIMAL(10, 2),
    sku_cost DECIMAL(10, 2),
    INDEX idx_sku (sku)
) ENGINE=InnoDB
SELECT sku, SUM(daily_sell_price) AS sell_price, SUM(profit) AS profit,sum(sku_cost) as sku_cost,
FROM t_sku_analy
WHERE stati_time >= '2023-04-01 00:00:00' AND stati_time <= '2023-04-30 00:00:00'
GROUP BY sku;

 

posted @ 2023-06-08 17:24  骚哥  阅读(102)  评论(0编辑  收藏  举报