TAILIEUCHUNG - Hướng dẫn học Microsoft SQL Server 2008 part 97

Con trỏ ngưỡng Các tài sản ngưỡng con trỏ bộ số hàng trong một con trỏ đặt trước keysets con trỏ được tạo ra không đồng bộ. Tối ưu hoá truy vấn số ước lượng số hàng đó sẽ được trả về từ các tập kết quả. Nếu ước tính số hàng lớn hơn ngưỡng con trỏ, sau đó con trỏ được tạo ra không đồng bộ, nếu không, nó được tạo ra đồng bộ, gây ra sự chậm trễ | Part VI Enterprise Data Management Cursor-Configuration Properties TABLE 39-8 Property Level Graphic Control Code Option Cursor Threshold S Management Studio EXEC sp_configure cursor threshold Cursor Close on Commit SDC Management Studio ALTER DATABASE DB Name SET cursor_close_on_commit Cursor Default D Management Studio ALTER DATABASE DB Name SET cursor_default The configuration level refers to Server Database or Connection. r - For information about cursor concepts writing and avoiding cursors refer to Chapter 22 Kill the Cursor P Cursor threshold The cursor threshold property sets the number of rows in a cursor set before the cursor keysets are generated asynchronously. The Query Optimizer estimates the number of rows that will be returned from the result set. If the estimated number of rows is greater than the cursor threshold then the cursor is generated asynchronously otherwise it is generated synchronously causing a delay because the query has to wait until all the rows are fetched. Every cursor keyset will be generated asynchronously if the cursor threshold property is set to 0. The default of -1 causes all keysets to be generated synchronously which is OK for smaller keysets. For larger cursor keysets though this may be a problem. In Management Studio the cursor threshold option can be set to the desired value in the Cursor threshold box in the Server Properties Advanced tab refer to Figure 39-9 . When you are working with cursors the following code will permit synchronous cursor keysets for cursors of up to 10 000 rows EXEC sp_configure show advanced options 1 RECONFIGURE EXEC sp_configure cursor threshold 10000 RECONFIGURE Cursor close on commit This property will close an open cursor after a transaction is committed when set to ON. If it is set to OFF the default then cursors remain open across transactions until a close cursor statement is issued. 922 Configuring SQL Server 39 The CURSOR_CLOSE_ON_COMMIT option can be set from .