Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Hash value generation times Expand / Collapse
Author
Message
Posted Monday, March 11, 2013 9:16 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Today @ 10:45 AM
Points: 489, Visits: 2,138
I have a table with 56 million rows. I performed the following operation:

ALTER TABLE MyBigTable ADD NewHashColumn AS HASHBYTES('SHA2_512', Column1+Column2+Column3)

The operation took a fraction of a second to complete. How is this possioble?! I mean can SQL Server really generate so many hash keys in such space of time?!

I'm guessing that the table was already in memory and all this operation took place in memory? Will the next checkpoint write the actual hash codes to the disk?


-----------------------------------
http://www.SQL4n00bs.com
Post #1429334
Posted Monday, March 11, 2013 10:17 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Today @ 4:30 PM
Points: 421, Visits: 776
If I were to guess from my limited knowledge of Hashbytes that this is treated like a computed column and doesn't actually store anything, only returning a value on select.
Post #1429375
Posted Monday, March 11, 2013 10:20 AM


SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Today @ 10:45 AM
Points: 489, Visits: 2,138
That makes perfect sense. Thanks for the clarification.

-----------------------------------
http://www.SQL4n00bs.com
Post #1429379
Posted Tuesday, March 12, 2013 5:48 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 11:14 PM
Points: 6,706, Visits: 11,738
If you had added PERSISTED when adding the computed column there is a possibility you might still be waiting for that complete

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1429703
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse