c# - Another class instead of SHA1Managed to making Checksum's with fewer than 128 length bytes -


I have a table that contains a column (AbsoluteUrl NVARCHAR (2048)) and I want to query this column, So it took a long time to compare each record with my own string. At least this table has 1000000 records.

Now I feel that there is a better solution for creating checksum for each AbsoluteUrl and comparing checksum rather than AbsoluteUrl columns. Therefore, I am using the method below to generate the checksum. But I need another class which make less than 128 checksum length bytes.

  public static byte [] GenerateChecksumAsByte (string content) {var buffer = Encoding.UTF8.GetBytes (content); Manage new SHA1 (). ComputeHash; }  

And is it good for my work?

UPDATE

According to the answer, I want to explain in more depth, then in fact I am working on a very simple web search engine. If I say briefly that I have to say that when all the web page URLs are extracted (collection of the URL) then I am going to the index of the URL table.

UrlId uniqueidentifier NotNull Primary Key (Clustered Index) AbsoluteUrl nvarchar (2048) Noonal checksum verb (128) noonal

Then I find the first table if I have the same URL which is the first Or is not indexed. If not, then create a new record.

  Obtain a public URL (byte [] checksum) {return _dataContext.Urls.SingleOrDefault (url = & gt; url.Checksum == checksum); // Inquire directly from AbsoluteUrl field}  

Save more method.

  Save the public zeros (url URL) {if (url == null) ArgumentNullException ("uRL"); Var Basic = _dataContext.Urls.GetOriginalEntityState (url); If (original == tap) {_dataContext.Urls.Attach (url); _dataContext.Refresh (Refresh Mode.ChipntWalz, URL); } Else _dataContext.Urls.InsertOnSubmit (url); _dataContext.SubmitChanges (); }  

For example, if I get 2,000 URLs on a page, I have to search 2000 times.

No, this is not a good way.

One million records for a indexed field is not a big deal. On the other hand, any checksum / hash / whatever you generate is capable of false positivity due to pigeon theory (aka birthday paradox). This reduces the larger, but does not end this chance, but it works in slow motion, where no speed will increase.

Just slip an index on the field and see what happens.


Comments