views:

239

answers:

1

I'm creating a table to hold items from rss feeds and I need to create a column 'description'. I selected the datatype as TEXT with no limit set with no index on this column. This is the error I'm getting:

#1071 - Specified key was too long; max key length is 1000 bytes

If I select to index this column, I get this error message:

#1170 - BLOB/TEXT column 'description' used in key specification without a key length

Any length I specify for this column returns the first error I got. Can someone tell me what I'm doing wrong? Thanks!

UPDATE:

I'm using MySQL 5.0.4

Here is the query I'm using to create the table:

CREATE TABLE  `feed_items` (

`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`feed_id` INT NOT NULL COMMENT  '`feeds`.`id`',
`guid` VARCHAR( 255 ) NOT NULL ,
`publish_date` DATETIME NOT NULL ,
`update_of` INT NULL COMMENT  '`feed_items`.`id`',
`link` VARCHAR( 255 ) NOT NULL ,
`title` VARCHAR( 255 ) NOT NULL ,
`description` TEXT NOT NULL ,
`comments_link` VARCHAR( 255 ) NULL ,
INDEX (  `feed_id` ,  `guid` ,  `publish_date` ,  `update_of` ,  `title` )
) ENGINE = MYISAM
+1  A: 

Even though it was from a while, this bug report seems to be what you are having an issue with: http://bugs.mysql.com/bug.php?id=4541

You may want to read through the comments on this bug, and see if they are referring to your situation, since it is hard to help without seeing what command you used to get this error, nor knowing which version of mysql.

UPDATE: Based on your query, you may want to remove this first:

INDEX (  `feed_id` ,  `guid` ,  `publish_date` ,  `update_of` ,  `title` )

Then, try doing:

INDEX (  `feed_id`)

When I see a long index like this I get suspicious.

Ideally you should index what you will be doing selects on, so unless you have

SELECT * FROM table WHERE feed_id=? AND guid=? AND publish_date=? AND update_of=? and title=?

then this index is useless. Since feed_id is a primary key you should just do

SELECT * FROM table where feed_id=?

as it will uniquely return one row.

So the index I have above would be what is needed. You may also want a separate index on title and perhaps publish_date.

Look at what queries you are writing, then you can determine where indexes should be. Indexes will get expensive as you add more rows, so you don't want to index too much, but indexing too little is useless, so that is why I suggest you look at the queries then decide where to have indexes.

James Black
I've posted updated information in the question. The error states that the max key length is 1000. I assume that key means the column is being indexed but the description column has no index placed on it. Am I wrong in this assumption? My experience with database design is limit. Thanks!
Kylee
You may want to try shortening your index. Unless you will be doing selects on all of these at once, I expect that that is your problem.
James Black
That did it. Reducing the indexes. I removed the indexes of the columns that I wouldn't be doing a SELECT on a majority of the time. Thanks!
Kylee