hi, i have a table that have one column (AbsoluteUrl NVARCHAR(2048)) and i want to querying on this column, so this took long time to comparing each records with my own string. at least this table have 1000000 records.
Now i think there is better solution to making a checksum for each AbsoluteUrl and compare to checksum together instead of to AbsoluteUrl column. so i'm use below method to generate checksum. but i want another class to making checksum's with fewer than 128 length bytes.
public static byte[] GenerateChecksumAsByte(string content)
{
var buffer = Encoding.UTF8.GetBytes(content);
return new SHA1Managed().ComputeHash(buffer);
}
And is this approach good for my work?
UPDATE
According to answers, i want to explain in more depth. so actually I'm work on very simple Web Search Engine. If I want to briefly explain that I have to say when all of urls of web page are extracted (collection of found urls) then I'm going to index that to Urls table.
UrlId uniqueidentifier NotNull Primary Key (Clustered Index) AbsoluteUrl nvarchar(2048) NoyNull Checksum varbinary(128) NotNull
So i first search the table to if i have same url which is indexed before or not. if not then create new record.
public Url Get(byte[] checksum)
{
return _dataContext.Urls.SingleOrDefault(url => url.Checksum == checksum);
//Or querying by AbsoluteUrl field
}
And Save method.
public void Save(Url url)
{
if (url == null)
throw new ArgumentNullException("url");
var origin = _dataContext.Urls.GetOriginalEntityState(url);
if (origin == null)
{
_dataContext.Urls.Attach(url);
_dataContext.Refresh(RefreshMode.KeepCurrentValues, url);
}
else
_dataContext.Urls.InsertOnSubmit(url);
_dataContext.SubmitChanges();
}
For example if on one page i found 2000 urls, i must search for 2000 times.