Skip navigation links

MySQL Forums :: Table Space :: Indexes on Text Fields


Advanced Search

Re: Indexes on Text Fields
Posted by: Rick James ()
Date: November 29, 2010 09:20AM

How big are the values for this field? If they are not 'too' big, then switch from TEXT to VARCHAR and from BLOB to VARBINARY.

VARCHAR and VARBINARY have a limit of 65535, but to index such a field, the limit is about 1000. Show us the CREATE TABLE you would like; then I can be more specific.

The '(...)' it is referring to is a "prefix" index. This is generally a useless type of index. Example of a case where it _might_ be useful:
CREATE TABLE foo (
    url TEXT NOT NULL,
    INDEX(url(100))
);
This says to index the first 100 characters of the `url` field. It is a way around the restriction of now big an index can be. But it often leads to an index that is never used.

TINYTEXT and TINYBLOB have a limit of 255. There is (perhaps) no reason to use them instead of VARCHAR(255) and VARBINARY(255). The TINYs cannot be INDEXed; the VARs can be.

Options: ReplyQuote


Subject Views Written By Posted
Indexes on Text Fields 1937 Valentine Andreev 11/28/2010 05:49AM
Re: Indexes on Text Fields 1035 Rick James 11/29/2010 09:20AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.