我有一个非常简单的查询,我在 Azure SQL 数据仓库中运行,但执行大约需要 40 秒。
表定义:
CREATE TABLE dbo.orders
(
location_code VARCHAR(8) NOT NULL,
order_date DATETIME NOT NULL,
order_status_code INT NOT NULL,
order_type_code VARCHAR(1) NULL,
coupon_code VARCHAR(8) NULL,
coupon_amount MONEY NOT NULL,
subtotal MONEY NOT NULL,
total_amount MONEY NULL,
order_number INT NOT NULL,
customer_code INT NOT NULL
)
WITH
(
DISTRIBUTION = ROUND_ROBIN,
CLUSTERED COLUMNSTORE INDEX
)
查询是:
SELECT location_code,
order_date,
order_status_code,
order_type_code,
coupon_code,
coupon_amount,
subtotal,
total_amount,
order_number,
customer_code
FROM orders WITH (nolock)
WHERE order_date >= '2016-04-01'
AND order_date <= '2016-04-30'
AND order_status_code < 99
表中有 13,083,667 条记录。任何人都可以帮助我优化这个。我为此提供了 100 个 DWU。
提前致谢。