【问题标题】:Sql Server 2019 Batch mode on rowstore feature not working行存储功能上的 Sql Server 2019 批处理模式不起作用
【发布时间】:2021-05-14 04:46:31
【问题描述】:

我在本地机器上安装了 sql server 2019 开发者版,我试图通过关注 https://www.sqlshack.com/query-tuning-with-sql-server-2019/ 文章来使用“行存储上的批处理模式”功能

我做了以下步骤

ALTER DATABASE [datatbase name] SET COMPATIBILITY_LEVEL = 150;

ALTER DATABASE SCOPED CONFIGURATION SET BATCH_MODE_ON_ROWSTORE = ON;

但执行计划仍然显示“实际执行模式 = 行”而不是批处理。

以下是示例查询

SET STATISTICS IO, TIME ON
GO

SELECT orderDetail_productID, SUM(orderDetail_price) SumUnitPrice, AVG(orderDetail_price) AvgUnitPrice,
SUM(orderDetail_Quantity) SumOrderQty, AVG(orderDetail_Quantity) AvgOrderQty
FROM [dbo].[tbl_orderDetail]
GROUP BY orderDetail_productID ORDER BY orderDetail_productID
GO

SET STATISTICS IO, TIME OFF
GO"

【问题讨论】:

  • 不相关,但请注意:在列名前加上表的表是一个非常糟糕的习惯。这意味着你有像tbl_orderDetail.orderDetail_productID 这样的列名。您已经知道它在表tbl_orderDetail 中,因为当您引用它时,它来自所述表。 orderDetail.productID 会好得多,甚至可以将表别名为oD,然后它可以是oD.productID。

标签: sql sql-server sql-server-2019


【解决方案1】:

只能在开发者版和企业版中使用 sql 2019 的行存储批处理模式。

一般规则:

-In the Query at least one table must have not less than 131072 rows
-Should be present at least an efficient batch operator (join, aggregate or window aggregate)
-At least one of the batch operators should have in input no fewer than 131072 rows.

看看@SQL Server 2019 and the Batch Mode on Rowstore

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-04
    • 2019-04-24
    • 2021-12-28
    • 2013-01-13
    • 2020-04-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多