-- ===============================================================================================================
-- Inserting data into disk-based tables using interpreted T-SQL
-- ===============================================================================================================
-- Delete data if exists
DELETE FROM [product_disk]
GO
DECLARE @starttime DATETIME2 = SYSDATETIME(),
@timems INT
DECLARE @key INT = 1
DECLARE @rowcount INT = 100000
DECLARE @description NCHAR(48) = N'Product0123456789012345678901234567890'
BEGIN TRAN
WHILE @key <= @ROWCOUNT
BEGIN
INSERT INTO [product_disk] VALUES (@key, @description)
SET @key += 1
END
COMMIT
SET @timems = DATEDIFF(ms, @starttime, SYSDATETIME())
SELECT 'Disk-based table and interpreted Transact-SQL: ' + CAST(@timems AS VARCHAR(10)) + ' ms'
-- ===============================================================================================================
-- Inserting data into disk-based tables using interpreted stored procedure
-- ===============================================================================================================
DELETE FROM [product_disk]
GO
SET STATISTICS TIME OFF
DECLARE @starttime DATETIME2 = SYSDATETIME(),
@timems INT
DECLARE @key INT = 1
DECLARE @rowcount INT = 100000
DECLARE @description NCHAR(48) = N'Product0123456789012345678901234567890'
SET @starttime = SYSDATETIME()
EXEC sp_insert_product_disk @rowcount, @description
SET @timems = DATEDIFF(ms, @starttime, SYSDATETIME())
SELECT 'Disk-based table and interpreted stored procedure: ' + CAST(@timems AS VARCHAR(10)) + ' ms'
-- ===============================================================================================================
-- Inserting data into memory-optimized table using interpreted T-SQL
-- ===============================================================================================================
--Delete data if exists
DELETE FROM [dbo].product_mem
GO
DECLARE @starttime DATETIME2 = SYSDATETIME(),
@timems INT
DECLARE @key INT = 1
DECLARE @rowcount INT = 100000
DECLARE @description NCHAR(48) = N'Product0123456789012345678901234567890'
SET @key = 1
SET @starttime = sysdatetime()
BEGIN TRAN
WHILE @key <= @rowcount
BEGIN
INSERT INTO product_mem VALUES (@key, @description)
SET @key += 1
END
COMMIT
SET @timems = DATEDIFF(ms, @starttime, SYSDATETIME())
SELECT 'Memory-optimized table w/hash index and interpreted Transact-SQL: ' + CAST(@timems AS VARCHAR(10)) + ' ms'
-- ===============================================================================================================
-- Inserting data into memory-optimized table using interpreted stored procedure
-- ===============================================================================================================
--Delete data if exists
DELETE FROM [dbo].product_mem
GO
DECLARE @starttime DATETIME2 = SYSDATETIME(),
@timems INT
DECLARE @rowcount INT = 100000
DECLARE @description NCHAR(48) = N'Product0123456789012345678901234567890'
SET @starttime = sysdatetime()
EXEC [dbo].sp_insert_product_mem @rowcount, @description
SET @timems = DATEDIFF(ms, @starttime, SYSDATETIME())
SELECT 'Memory-optimized table w/hash index and interpreted SP:' + CAST(@timems AS VARCHAR(10)) + ' ms'
-- ===============================================================================================================
-- Inserting data into memory-optimized table using native stored procedure
-- ===============================================================================================================
--Delete data if exists
DELETE FROM [dbo].product_mem
GO
DECLARE @starttime DATETIME2 = SYSDATETIME(),
@timems INT
DECLARE @rowcount INT = 100000
DECLARE @description NCHAR(48) = N'Product0123456789012345678901234567890'
SET @starttime = sysdatetime()
EXEC [dbo].sp_native_insert_product_mem @rowcount, @description
SET @timems = DATEDIFF(ms, @starttime, SYSDATETIME())
SELECT 'Memory-optimized table w/hash index and interpreted SP:' + CAST(@timems AS VARCHAR(10)) + ' ms'
0 comments:
Post a Comment