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

Generic Data Comparison Expand / Collapse
Author
Message
Posted Tuesday, August 24, 2004 6:28 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 12:43 PM
Points: 138, Visits: 269
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/lPey


Post #133683
Posted Wednesday, September 22, 2004 3:54 PM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Tuesday, May 6, 2014 5:51 AM
Points: 6,266, Visits: 2,028

As you said

"... The only danger with this solution, even though the chances are very slim, is that the different original values might produce the same hash and result will be wrong .."

Then, Why NOT just use ?

 CHECKSUM_AGG(BINARY_CHECKSUM(*))

That, is going to give you a real performance boost

ex:

SELECT
(SELECT   CHECKSUM_AGG(BINARY_CHECKSUM(*)) FROM processed_customer)
 -
(SELECT   CHECKSUM_AGG(BINARY_CHECKSUM(*)) FROM customer ) /* 0 means OK*/

Just my $0.02

 




* Noel
Post #138352
Posted Wednesday, September 22, 2004 4:03 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 12:43 PM
Points: 138, Visits: 269
Same problem. Chances are very slim.


Post #138353
Posted Wednesday, September 22, 2004 6:20 PM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Tuesday, May 6, 2014 5:51 AM
Points: 6,266, Visits: 2,028

"Same problem. Chances are very slim"

 

Yes but,

 1. the simplicity of the query

 2. the speed and

3. the generality  

are a lot better that the proposed solution

 




* Noel
Post #138373
Posted Wednesday, September 22, 2004 7:15 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 12:43 PM
Points: 138, Visits: 269

With binary conversion chances for the wrong result are smaller for the tables with 4+ columns. I was trying your method before I get proposed the other one. And actually, I was trying to calculate probability of two methods.

Yours method has more chances to give you bad result (even chances for both are very small for the tables with 4+ columns) 

The more  columns the cleaner the method with the binary column conversion and more chances with you method to have an error.

Yes, you have performance boost, but not as much as between solution 1-2-3 and 4. And in most cases this is not a point. When you doing such comparison the time (usually) is irrelevant



Post #138377
Posted Monday, August 8, 2005 11:56 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, September 27, 2012 10:43 PM
Points: 126, Visits: 56

The solution that converts data to varbinary and then to bigint appears to have a major limitation. Anytime you run through this conversion with more than 8 characters you risk ending up with the same bigint.  Data is being truncated with this conversion.

For example these queries both return the same result:

select convert(bigint,convert(varbinary(255),'VALUE001'))

select convert(bigint,convert(varbinary(255),'This is a very long string that will end up being the same as the previous one. VALUE001'))

Thanks,

Dan Wilson




Post #208430
Posted Monday, August 8, 2005 8:07 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Yesterday @ 12:43 PM
Points: 138, Visits: 269
Yes, you right, solution has some limitations and as I pointed it has a probability to get a wrong result. But in many cases this probability is small.


Post #208527
Posted Tuesday, September 27, 2005 2:20 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, December 6, 2006 2:08 PM
Points: 11, Visits: 1
I tried the third method today just on a lark for a new SP I created to import data.  The query runs on tables about 35k records long with 8 columns in about 2 seconds.  It did help me identify a problem with our legacy data (originally thought my new code was bad).  Thanks for sharing!


Post #224132
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse