dbTalk Databases Forums  

Fast look up of long (n)varchar

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Fast look up of long (n)varchar in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
John Bokma
 
Posts: n/a

Default Fast look up of long (n)varchar - 03-06-2006 , 12:12 PM






I have a table containing URLs. I want to be able to look up an URL very
fast, so I used an nvarchar to store the URL, and put an index on it
(maybe naive).

Anyway, I bump into:
"The index entry of length 911 bytes for the index 'UQ__URL__1367E606'
exceeds the maximum length of 900 bytes."

What's the best way to handle this? I want to do the look up fast. The
only thing I could think up was adding an extra column containing a digest
for the URL, and look up all URLs with the same digest, *and* having the
same value (which could give either 1 or 0 results).

I am new to MS SQL, so I might describe a silly solution, basically I want
to look up URLs to ID the fastest way possible.

--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

Reply With Quote
  #2  
Old   
Alexander Kuznetsov
 
Posts: n/a

Default Re: Fast look up of long (n)varchar - 03-06-2006 , 01:36 PM






John,

use an index on checksum(url), as described here:

http://www.devx.com/dbzone/Article/30786


Reply With Quote
  #3  
Old   
Doug
 
Posts: n/a

Default Re: Fast look up of long (n)varchar - 03-06-2006 , 10:41 PM



Quote:
Use an index on checksum(url), as described here:
oh wow. that is brilliant. I have never run into that before.

that is a GREAT idea that I am filing away for futures.

thank you!



Reply With Quote
  #4  
Old   
John Bokma
 
Posts: n/a

Default Re: Fast look up of long (n)varchar - 03-07-2006 , 12:56 PM



John Bokma <john (AT) castleamber (DOT) com> wrote:

Quote:
I have a table containing URLs. I want to be able to look up an URL
very fast, so I used an nvarchar to store the URL, and put an index on
it (maybe naive).

Anyway, I bump into:
"The index entry of length 911 bytes for the index 'UQ__URL__1367E606'
exceeds the maximum length of 900 bytes."

What's the best way to handle this? I want to do the look up fast. The
only thing I could think up was adding an extra column containing a
digest for the URL, and look up all URLs with the same digest, *and*
having the same value (which could give either 1 or 0 results).

I am new to MS SQL, so I might describe a silly solution, basically I
want to look up URLs to ID the fastest way possible.
To answer my own question: under CHECKSUM in SQL Server Books Online:

"The checksum index can be used as a hash index, particularly to improve
indexing speed when the column to be indexed is a long character column."

Comes with an example, etc.

--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.