Subject Re: [firebird-support] Weird... "keysize too big for index"
Author Helen Borrie
At 07:39 AM 15/03/2005 -0600, you wrote:

>I'll give it a go when I have a chance.
>
>The 25x byte count limit is a function of the engine, though. SQL, per
>se, does not define a limit (although Firebird SQL may enforce one).

Indeed it does. Ivan is right about the limit being 252, not 253. Ivan is
the arch-guru on indexing, btw. :-)


>VARCHAR(1) is 1 to 2 bytes. One byte for the length, and 1 byte for the
>(optional) data.

VARCHAR(1) stores a string of not more than one *character*. Varchars are
stored with 2 extra bytes, in which a 16-bit integer stores the character
length of the varchar. Therefore, a VARCHAR(1), stores zero or one
characters, which might be one, two or three bytes, depending on charset,
plus the two attribute bytes. It's the data bytes that are counted for
index length, not the attribute bytes.


>Try with CHAR(x) instead of VARCHAR(x).

Don't bother. CHARs have the same limitation; and a CHAR(252) isn't a hot
place to store a string of that size, unless you *really* have to store
fixed-length strings of that magnitude.

Anyway, the good news is that Firebird 2 lets you store ridiculously wide
indexes - up to the page size, minus 4, minus (I suppose) a few other bytes
that are earmarked for page pointers.

./heLen