Can I index just a smaller number of characters from a field even though the
field has more?
Will this make MySQL to index that field faster?

Teddy,
Teddy's Center: http://teddy.fcc.ro/
Email: [EMAIL PROTECTED]

----- Original Message -----
From: "Jeremy Zawodny" <[EMAIL PROTECTED]>
To: "David T-G" <[EMAIL PROTECTED]>
Cc: "mysql users" <[EMAIL PROTECTED]>
Sent: Tuesday, December 31, 2002 1:47 AM
Subject: Re: indexing a blob


On Mon, Dec 30, 2002 at 04:53:08PM -0500, David T-G wrote:
>
> Hi, all --
>
> Having learned a bit about indexes, I have tried to practice a bit.  So
> far things work for my char(20) fields, but I have a problem with a
> tinyblob.  To wit:
>
>   create table ccards
>   (
>     # ID number
>     id smallint not null default 0 auto_increment primary key ,
>     type smallint not null , # references ccardtypes.id
>     name char(40) not null , # name as on card
>     number tinytext not null , # card number
>     expdate date not null , # expiration date
>     hashsum tinyblob not null , # hash of the card: have we seen this one?
>     index (hashsum) # for quick lookups
>   ) ;
>
> Whenever I try this with the index, I get
>
>   ERROR 1170 at line 49: BLOB column 'hash' used in key specification
>   without a key length
>
> I don't know where the key length needs to be specified; I tried
>
>   hashsum tinyblob(255) not null
>
> but that puked at the create stage :-)

Try this:

     index (hashsum(123)) # for quick lookups

Where 123 is the number of characters/bytes to index.

Jeremy
--
Jeremy D. Zawodny     |  Perl, Web, MySQL, Linux Magazine, Yahoo!
<[EMAIL PROTECTED]>  |  http://jeremy.zawodny.com/

MySQL 3.23.51: up 15 days, processed 557,369,159 queries (408/sec. avg)

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to