我有以下情况: 我有一个SQL 2008 R2企业版,我在其中一个数据库中启用了TDE加密。加密数据库中的一个存储过程使用表变量(@ t1),该表填充了近600K记录。然后有一个select语句,它使用此表与加密数据库中的另一个表(t2)之间的连接,在t2表上我有大约20密耳行。 这个连接需要永远完成(上次花了将近4小时)。如果我使用表变量而不是tempoarary表(#t3)并进行相同的连接,则结果是即时的。此外,如果我在另一台没有TDE加密的服务器(相同的SQL 2008 R2)中运行这两个表之间的连接,则连接在几秒钟内完成 那么有人使用TDE遇到表变量和加密数据库的类似问题吗? 这就是我加密数据库的方式:
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'AASFA234234234as234#234#$##$'
CREATE CERTIFICATE SQLCertificate
WITH SUBJECT = 'SQL Certificate',
EXPIRY_DATE = '10/31/2020';
USE DBTest
go
CREATE DATABASE ENCRYPTION KEY
WITH ALGORITHM = AES_256
ENCRYPTION BY SERVER CERTIFICATE SQLCertificate;
ALTER DATABASE DBTest
SET ENCRYPTION ON
And this is the script that I used where _rptHousehold is a table that has 18mil records. The script never gets to the PRINT '3 ' + CONVERT(VARCHAR,GETDATE(),121), hangs on the select count(*) from @tt
PRINT '1 ' + CONVERT(VARCHAR,GETDATE(),121)
IF object_id('tempdb..#tt') IS NOT NULL
DROP TABLE #tt
declare @tt table
( [id] int IDENTITY(1,1),
TableID DECIMAL(11,0),
AdvisorID INT,
idBuild INT,
Tablename sysname,
tCreatedate datetime,
ColumnName varchar(100),
Column_ID int,
qtyValue decimal(25,9),
tModifiedDate datetime
)
INSERT INTO @tt
(TableID , AdvisorID , idBuild,Tablename, tCreatedate,ColumnName, Column_ID,qtyValue )
select TOP 600000
t.object_ID
,AdvisorID
,1635
,t.NAME
,t.Create_date
,c.Name
,c.object_ID
,CAST(RAND()* 100000 AS DECIMAL(25,9))
FROM sys.tables t CROSS JOIN sys.columns c
CROSS JOIN (SELECT DISTINCT idAdvisor AS AdvisorID FROM dbo._rptHousehold WHERE idBuild = 1635) ac
PRINT '2 ' + CONVERT(VARCHAR,GETDATE(),121)
SELECT COUNT(*) FROM @tt
PRINT '3 ' + CONVERT(VARCHAR,GETDATE(),121)
UPDATE tt
SET
qtyValue = rp.qtyAvgPAAssets
FROM @tt tt
JOIN _rptHousehold rp
ON rp.idAdvisor= tt.AdvisorID
AND rp.idBuild= tt.idBuild
PRINT '4 ' + CONVERT(VARCHAR,GETDATE(),121)
答案 0 :(得分:1)
我认为它不直接与TDE连接,因为TDE在写入磁盘时对数据进行加密,并在从磁盘读取数据时对其进行解密,并且开销被认为不是那么大(<10%)。