Home
%3CLINGO-SUB%20id%3D%22lingo-sub-1059191%22%20slang%3D%22en-US%22%3EInternals%20of%20TDE%20Encryption%20scan%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1059191%22%20slang%3D%22en-US%22%3E%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3ETransparent%20Data%20Encryption%20(TDE)%20is%20a%20mechanism%20in%20SQL%20Server%20to%20secure%20the%20data%20and%20log%20files%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eat%20rest%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eby%20encrypting%20them%20using%20a%20key%2Fcertificate.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EMany%20customers%20use%20this%20feature%20to%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eprotect%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Btheir%20data%20against%20security%20threats.%20Other%20than%20knowing%20that%20this%20feature%20encrypts%20the%20data%2C%20there%20are%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eother%20aspects%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bthat%20would%20really%20be%20useful%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Efor%20you%20to%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Baware%20of.%20Especially%20about%20how%20it%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Emay%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eimpact%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eyour%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EOLTP%20workload%2C%20disk%2C%20memory%20and%20other%20things.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3ESo%2C%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Blet%E2%80%99s%20dig%20straight%20in.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAs%20a%20rule%20of%20thumb%2C%20keep%20in%20mind%20that%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%20style%3D%22text-align%3A%20justify%3B%22%3E%0A%3CLI%20data-leveltext%3D%22%EF%82%B7%22%20data-font%3D%22Symbol%22%20data-listid%3D%221%22%20aria-setsize%3D%22-1%22%20data-aria-posinset%3D%220%22%20data-aria-level%3D%221%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAll%20the%20data%20in-memory%20(%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ei.e.%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EBuffer%20Pool)%20is%20always%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Edecrypted%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B134233279%26quot%3B%3Atrue%2C%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%20data-leveltext%3D%22%EF%82%B7%22%20data-font%3D%22Symbol%22%20data-listid%3D%221%22%20aria-setsize%3D%22-1%22%20data-aria-posinset%3D%220%22%20data-aria-level%3D%221%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAll%20the%20data%20on%20disk%20is%20encrypted%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B134233279%26quot%3B%3Atrue%2C%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EWhen%20users%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bturn%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EON%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bencryption%20on%20their%20database%20using%20the%20below%20command%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%20padding-left%3A%2030px%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20style%3D%22text-align%3A%20justify%3B%20padding-left%3A%2030px%3B%22%3E%3CSPAN%20data-contrast%3D%22none%22%3EALTER%20DATABASE%20%5Btestdb%5D%20SET%20ENCRYPTION%20ON%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559731%26quot%3B%3A720%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FPRE%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3ETwo%20things%20should%20happen%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3COL%20style%3D%22text-align%3A%20justify%3B%22%3E%0A%3CLI%20data-leveltext%3D%22(%251)%22%20data-font%3D%22%22%20data-listid%3D%222%22%20aria-setsize%3D%22-1%22%20data-aria-posinset%3D%221%22%20data-aria-level%3D%221%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAll%20the%20existing%20user%20data%20on%20the%20files%20should%20be%20encrypted%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B134233279%26quot%3B%3Atrue%2C%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%20data-leveltext%3D%22(%251)%22%20data-font%3D%22%22%20data-listid%3D%222%22%20aria-setsize%3D%22-1%22%20data-aria-posinset%3D%221%22%20data-aria-level%3D%221%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAny%20new%20writes%20to%20the%20disk%20(say%20a%20new%20page%20allocated%2C%20file%20growth%20etc)%20should%20also%20be%20encrypted.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B134233279%26quot%3B%3Atrue%2C%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3ETo%20achieve%20(1)%2C%20we%20start%20something%20called%20a%26nbsp%3B%3C%2FSPAN%3E%3CI%3E%3CSPAN%20data-contrast%3D%22auto%22%3ETDE%20Encryption%20Scan.%3C%2FSPAN%3E%3C%2FI%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3BMore%20on%20this%20shortly.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3ETo%20achieve%20(2)%2C%20any%20write%20to%20disk%20during%20a%20flush%20(For%20example%2C%20any%20form%20of%20checkpoint%2C%20page%20evicted%20from%20Buffer%20Pool%26nbsp%3Betc)%20will%20be%20encrypted%20before%20the%20page%20is%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ewritten%20to%20disk.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EBefore%20any%20flush%2C%20we%20see%20if%20TDE%20Encryption%20is%20enabled%20on%20the%20database%2C%20and%20if%20so%2C%20we%20encrypt%20before%20we%20write.%20As%20simple%20as%20that.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH4%20style%3D%22text-align%3A%20justify%3B%22%20aria-level%3D%222%22%20id%3D%22toc-hId--739143985%22%20id%3D%22toc-hId--739143985%22%3E%3CSPAN%20data-contrast%3D%22none%22%3ETDE%20Encryption%20Scan%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559738%26quot%3B%3A40%2C%26quot%3B335559739%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FH4%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3ENow%2C%20once%20encryption%20is%20turned%20ON%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Efor%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ea%20database%2C%20all%20the%20existing%20user%20data%20on%20the%20data%20files%20should%20be%20encrypted.%20To%20do%20this%2C%20SQL%20Server%20starts%20something%20called%20a%20TDE%20Encryption%20Scan.%20It%20is%20basically%20a%20scanner%2C%20which%20goes%20through%20each%20page%20of%20each%20data%20file%20to%20ensure%20its%20encrypted.%20When%20the%20scanner%20completes%20its%20scan%20across%20all%20the%20files%2C%20that%E2%80%99s%20when%20we%20say%20that%20the%20database%20is%20%E2%80%98encrypted%E2%80%99.%20How%20the%20TDE%20Encryption%20scan%20works%20is%20crucial%20because%20of%20the%20effects%20it%20can%20have%20on%20the%20user%20workload.%20Let%20me%20explain.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EConsider%20a%20database%20contains%2010%20data%20files%2C%20each%20100%20GB.%20That%E2%80%99s%20~1TB%20of%20data.%20When%20user%20turns%20ON%20encryption%2C%20the%20goal%20is%20to%20encrypt%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eall%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bthis%201TB%20of%20data%20on%20disk.%20Now%2C%20as%20soon%20as%20encryption%20is%20turned%20ON%2C%20we%20mentioned%20that%20any%20write%20or%20flush%20that%20happens%20to%20disk%20will%20be%20encrypted%20before%20the%20flush.%20SQL%20Server%20utilizes%20this%20and%20the%20TDE%20Scanner%20is%20built%20around%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ethis%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bconcept.%20Below%20chart%20explains%20how%20a%20TDE%20Encryption%20scan%20works.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F161010i0947DA129054485C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22clipboard_image_0.png%22%20title%3D%22clipboard_image_0.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EWhen%20user%20turns%20ON%20encryption%2C%20a%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3ESQL%20Server%20worker%20thread%20(denoted%20in%20Blue)%20will%20perform%20an%20initial%20validation%2C%20start%20an%26nbsp%3B%3C%2FSPAN%3E%3CI%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAsynchronous%20Encryption%20Worker%20thread%3C%2FSPAN%3E%3C%2FI%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B(denoted%20in%20Green)%20and%20simply%20exit.%20The%26nbsp%3B%3C%2FSPAN%3E%3CI%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAsynchronous%20Encryption%20worker%26nbsp%3B%3C%2FSPAN%3E%3C%2FI%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ewill%20then%20spawn%20multiple%26nbsp%3B%3C%2FSPAN%3E%3CI%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAsynchronous%20Disk%20Worker%20threads%3C%2FSPAN%3E%3C%2FI%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B(denoted%20in%20Orange)%20and%20wait%20for%20them%20to%20finish.%20Once%20the%26nbsp%3B%3C%2FSPAN%3E%3CI%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAsynchronous%20Disk%20Workers%3C%2FSPAN%3E%3C%2FI%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bfinish%20their%20task%2C%20the%26nbsp%3B%3C%2FSPAN%3E%3CI%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAsynchronous%20Encryption%20worker%3C%2FSPAN%3E%3C%2FI%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bwill%20perform%20a%20checkpoint%2C%20set%20the%20final%20state%20of%20database%20as%26nbsp%3B%3C%2FSPAN%3E%3CI%3E%3CSPAN%20data-contrast%3D%22auto%22%3EEncrypted%26nbsp%3B%3C%2FSPAN%3E%3C%2FI%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eand%20exit.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EHow%20many%26nbsp%3B%3C%2FSPAN%3E%3CI%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAsynchronous%20Disk%20Worker%26nbsp%3B%3C%2FSPAN%3E%3C%2FI%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ethreads%20are%20spawn%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eed%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%3F%26nbsp%3B%3C%2FSPAN%3E1%20per%20volume.%26nbsp%3B%3CSPAN%20data-contrast%3D%22auto%22%3Ei.e.%2C%20If%20there%20are%2010%20data%20files%20on%2010%20different%20volumes%2C%20then%2010%20workers%2C%20and%20if%2010%20data%20files%20on%20same%20volume%2C%20then%20just%201%20worker.%20This%20is%20to%20minimize%20the%20impact%20of%20the%20TDE%20Encryption%20scan%20on%20the%20disk.%20For%20simplicity%2C%20lets%20consider%20there%20is%201%20thread%20per%20data%20file.%20What%20does%20the%26nbsp%3B%3C%2FSPAN%3E%3CI%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAsynchronous%20Disk%20Worker%3C%2FSPAN%3E%3C%2FI%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bdo%3F%20It%20just%20loops%20through%20each%20page%20of%20the%20file%20(Each%20page%20is%208KB)%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%2C%20reads%20it%20into%20the%20memory%20(In%20batches%20of%204%20Extents%20or%2032%20Pages)%20and%20marks%20them%20dirty.%20It%20also%20creates%20a%20log%20record%20(to%20be%20replayed%20in%20secondary).%20Simple%20right%3F%20So%2C%20where%20does%20the%20encryption%20occur%3F%20Remember%20that%20we%20encrypt%20pages%20only%20during%20flush%3F%20Once%20all%20the%26nbsp%3B%3C%2FSPAN%3E%3CI%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAsynchronous%20Disk%20Workers%3C%2FSPAN%3E%3C%2FI%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bdirty%20all%20the%20pages%20of%20all%20data%20files%2C%20the%26nbsp%3B%3C%2FSPAN%3E%3CI%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAsynchronous%20Encryption%20worker%3C%2FSPAN%3E%3C%2FI%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bwho%20is%20waiting%20for%20these%20workers%20to%20finish%2C%20performs%20a%20checkpoint%20which%20will%20encrypt%20all%20the%20dirty%20pages%20and%20flush%20them%20to%20disk.%20This%20is%20when%20all%20the%20pages%20of%20the%20database%20are%20fully%20encrypted.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%20aria-level%3D%222%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20style%3D%22text-align%3A%20justify%3B%22%20aria-level%3D%222%22%20id%3D%22toc-hId-1748368848%22%20id%3D%22toc-hId-1748368848%22%3E%3CSPAN%20data-contrast%3D%22none%22%3EWhy%20is%20this%20important%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22none%22%3E%3F%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559738%26quot%3B%3A40%2C%26quot%3B335559739%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FH4%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EWe%20have%20multiple%20workers%20dirtying%20each%20page%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ew%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ehile%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Echeckpointing%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eperforms%20the%20encryption.%20For%20this%20to%20happen%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%20style%3D%22text-align%3A%20justify%3B%22%3E%0A%3CLI%20data-leveltext%3D%22%EF%82%B7%22%20data-font%3D%22Symbol%22%20data-listid%3D%221%22%20aria-setsize%3D%22-1%22%20data-aria-posinset%3D%220%22%20data-aria-level%3D%221%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAll%20the%20pages%20need%20to%20be%20read%20into%20the%20memory%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B(Requires%20memory%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Band%20disk%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bresource)%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B134233279%26quot%3B%3Atrue%2C%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%20data-leveltext%3D%22%EF%82%B7%22%20data-font%3D%22Symbol%22%20data-listid%3D%221%22%20aria-setsize%3D%22-1%22%20data-aria-posinset%3D%220%22%20data-aria-level%3D%221%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EEvery%20page%20needs%20to%20be%20encrypted%20(Requires%20CPU%20resource)%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B134233279%26quot%3B%3Atrue%2C%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%20data-leveltext%3D%22%EF%82%B7%22%20data-font%3D%22Symbol%22%20data-listid%3D%221%22%20aria-setsize%3D%22-1%22%20data-aria-posinset%3D%220%22%20data-aria-level%3D%221%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAll%20the%20pages%20need%20to%20be%20flushed%20to%20disk%20(Requires%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Ed%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eisk%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eresource)%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B134233279%26quot%3B%3Atrue%2C%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EPerforming%20a%20TDE%20Encryption%20scan%20is%20a%20resource%20intensive%20operation%20as%20it%20uses%20valuable%20resources%20on%20CPU%2C%20memory%20and%20IO%20which%20could%20otherwise%20be%20used%20for%20user%20workload.%20Naturally%2C%20there%20is%20an%20impact%20to%20the%20user%20workload%20if%20a%20TDE%20Encryption%20scan%20is%20running.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EThe%20exact%20same%20operations%20happen%20when%20an%20encrypted%20database%20is%20decrypted%2C%20or%20an%20encryption%20key%20is%20rotated%20as%20well.%20Except%20during%20decryption%2C%20the%20pages%20are%20not%20encrypted%20on%20flush.%20The%20scanner%20performs%20the%20exact%20same%20job%20of%20dirtying%20each%20page%20of%20the%20database.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CH4%20style%3D%22text-align%3A%20justify%3B%22%20aria-level%3D%222%22%20id%3D%22toc-hId--59085615%22%20id%3D%22toc-hId--59085615%22%3E%3CSPAN%20data-contrast%3D%22none%22%3EHow%20do%20we%20manage%20the%20resources%3F%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559738%26quot%3B%3A40%2C%26quot%3B335559739%26quot%3B%3A0%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FH4%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EHaving%20the%20data%20encrypted%20as%20soon%20as%20possible%20is%20vital%20in%20terms%20of%20security.%20But%20if%20it%20has%20impact%20on%20user%20workloads%2C%20users%20can%20then%20schedule%20the%20TDE%20Encryption%20scan%20accordingly.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EKnowing%20what%20resources%20are%20used%20by%20the%20TDE%20Encryption%20scan%20can%20help%20users%20allocate%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Esufficient%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bresources%20to%20their%20user%20workloads.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EUsers%20can%20also%20suspend%20the%20TDE%20Encryption%20scan%20using%20the%20below%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Equery%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20style%3D%22text-align%3A%20justify%3B%20padding-left%3A%2030px%3B%22%3E%3CSPAN%20data-contrast%3D%22none%22%3EALTER%20DATABASE%20%5Btestdb%5D%20SET%20ENCRYPTION%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22none%22%3ESUSPEND%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559731%26quot%3B%3A720%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FPRE%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EAnd%20resume%20using%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20style%3D%22text-align%3A%20justify%3B%20padding-left%3A%2030px%3B%22%3E%3CSPAN%20data-contrast%3D%22none%22%3EALTER%20DATABASE%20%5Btestdb%5D%20SET%20ENCRYPTION%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22none%22%3ERESUME%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559731%26quot%3B%3A720%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FPRE%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20style%3D%22text-align%3A%20justify%3B%22%3E%3CSPAN%20data-contrast%3D%22auto%22%3EThe%20DMV%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fsystem-dynamic-management-views%2Fsys-dm-database-encryption-keys-transact-sql%3Fview%3Dsql-server-ver15%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%3CSPAN%20data-contrast%3D%22none%22%3Esys.dm_database_encryption_keys%3C%2FSPAN%3E%3C%2FA%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bsurfaces%20information%20like%20the%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eencryption_state%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%2C%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eencryption_scan_state%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eetc%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bwhich%20can%20also%20be%20very%20useful%20to%20know%20what%20the%20scanner%20is%20doing%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eat%20any%20point%20in%20time%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E.%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1059191%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20data-contrast%3D%22auto%22%3ETransparent%20Data%20Encryption%20(TDE)%20is%20a%20mechanism%20in%20SQL%20Server%20to%20secure%20the%20data%20and%20log%20files%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eat%20rest%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eby%20encrypting%20them%20using%20a%20key%2Fcertificate.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EMany%20customers%20use%20this%20feature%20to%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eprotect%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Btheir%20data%20against%20security%20threats.%20Other%20than%20knowing%20that%20this%20feature%20encrypts%20the%20data%2C%20there%20are%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eother%20aspects%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Bthat%20would%20really%20be%20useful%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Efor%20you%20to%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Baware%20of.%20Especially%20about%20how%20it%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Emay%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eimpact%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3Eyour%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3EOLTP%20workload%2C%20disk%2C%20memory%20and%20other%20things.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3ESo%2C%3C%2FSPAN%3E%3CSPAN%20data-contrast%3D%22auto%22%3E%26nbsp%3Blet%E2%80%99s%20dig%20straight%20in.%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%20data-ccp-props%3D%22%7B%26quot%3B201341983%26quot%3B%3A0%2C%26quot%3B335551550%26quot%3B%3A6%2C%26quot%3B335551620%26quot%3B%3A6%2C%26quot%3B335559739%26quot%3B%3A160%2C%26quot%3B335559740%26quot%3B%3A259%7D%22%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1059191%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESQLServerStorageEngine%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESQLServerTiger%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Transparent Data Encryption (TDE) is a mechanism in SQL Server to secure the data and log files at rest by encrypting them using a key/certificate. Many customers use this feature to protect their data against security threats. Other than knowing that this feature encrypts the data, there are other aspects that would really be useful for you to aware of. Especially about how it may impact your OLTP workload, disk, memory and other things. So, let’s dig straight in.  

 

As a rule of thumb, keep in mind that 

  • All the data in-memory (i.e., Buffer Pool) is always decrypted 
  • All the data on disk is encrypted 

 

When users turn ON encryption on their database using the below command 

 

ALTER DATABASE [testdb] SET ENCRYPTION ON 

 

Two things should happen 

  1. All the existing user data on the files should be encrypted 
  2. Any new writes to the disk (say a new page allocated, file growth etc) should also be encrypted. 

To achieve (1), we start something called a TDE Encryption Scan. More on this shortly. 

To achieve (2), any write to disk during a flush (For example, any form of checkpoint, page evicted from Buffer Pool etc) will be encrypted before the page is written to disk. Before any flush, we see if TDE Encryption is enabled on the database, and if so, we encrypt before we write. As simple as that. 

 

TDE Encryption Scan 

Now, once encryption is turned ON for a database, all the existing user data on the data files should be encrypted. To do this, SQL Server starts something called a TDE Encryption Scan. It is basically a scanner, which goes through each page of each data file to ensure its encrypted. When the scanner completes its scan across all the files, that’s when we say that the database is ‘encrypted’. How the TDE Encryption scan works is crucial because of the effects it can have on the user workload. Let me explain. 

 

Consider a database contains 10 data files, each 100 GB. That’s ~1TB of data. When user turns ON encryption, the goal is to encrypt all this 1TB of data on disk. Now, as soon as encryption is turned ON, we mentioned that any write or flush that happens to disk will be encrypted before the flush. SQL Server utilizes this and the TDE Scanner is built around this concept. Below chart explains how a TDE Encryption scan works.

 

clipboard_image_0.png

 

 

When user turns ON encryption, a SQL Server worker thread (denoted in Blue) will perform an initial validation, start an Asynchronous Encryption Worker thread (denoted in Green) and simply exit. The Asynchronous Encryption worker will then spawn multiple Asynchronous Disk Worker threads (denoted in Orange) and wait for them to finish. Once the Asynchronous Disk Workers finish their task, the Asynchronous Encryption worker will perform a checkpoint, set the final state of database as Encrypted and exit.  

 

How many Asynchronous Disk Worker threads are spawned1 per volume. i.e., If there are 10 data files on 10 different volumes, then 10 workers, and if 10 data files on same volume, then just 1 worker. This is to minimize the impact of the TDE Encryption scan on the disk. For simplicity, lets consider there is 1 thread per data file. What does the Asynchronous Disk Worker do? It just loops through each page of the file (Each page is 8KB), reads it into the memory (In batches of 4 Extents or 32 Pages) and marks them dirty. It also creates a log record (to be replayed in secondary). Simple right? So, where does the encryption occur? Remember that we encrypt pages only during flush? Once all the Asynchronous Disk Workers dirty all the pages of all data files, the Asynchronous Encryption worker who is waiting for these workers to finish, performs a checkpoint which will encrypt all the dirty pages and flush them to disk. This is when all the pages of the database are fully encrypted. 

 

Why is this important? 

We have multiple workers dirtying each page while checkpointing performs the encryption. For this to happen,  

  • All the pages need to be read into the memory (Requires memory and disk resource) 
  • Every page needs to be encrypted (Requires CPU resource) 
  • All the pages need to be flushed to disk (Requires disk resource) 

Performing a TDE Encryption scan is a resource intensive operation as it uses valuable resources on CPU, memory and IO which could otherwise be used for user workload. Naturally, there is an impact to the user workload if a TDE Encryption scan is running.  

The exact same operations happen when an encrypted database is decrypted, or an encryption key is rotated as well. Except during decryption, the pages are not encrypted on flush. The scanner performs the exact same job of dirtying each page of the database. 

 

How do we manage the resources? 

Having the data encrypted as soon as possible is vital in terms of security. But if it has impact on user workloads, users can then schedule the TDE Encryption scan accordingly. Knowing what resources are used by the TDE Encryption scan can help users allocate sufficient resources to their user workloads. Users can also suspend the TDE Encryption scan using the below query 

 

ALTER DATABASE [testdb] SET ENCRYPTION SUSPEND 

 

And resume using 

 

ALTER DATABASE [testdb] SET ENCRYPTION RESUME 

 

The DMV sys.dm_database_encryption_keys surfaces information like the encryption_stateencryption_scan_state etc which can also be very useful to know what the scanner is doing at any point in time.