1

Have the following table structure:

CREATE TABLE `PARSER_U_R_L` (
  `PARSER_ID` varchar(20) COLLATE latin1_general_cs NOT NULL,
  `URL_MD5` varchar(255) COLLATE latin1_general_cs NOT NULL,
  `ENTRY_POINT_ID` varchar(20) COLLATE latin1_general_cs DEFAULT NULL,
  `TYPE_ID` varchar(20) COLLATE latin1_general_cs DEFAULT NULL,
  `STATUS_ID` varchar(20) COLLATE latin1_general_cs DEFAULT NULL,
  `INDEXED_TIME` datetime DEFAULT NULL,
PRIMARY KEY (`PARSER_ID`,`URL_MD5`),
  KEY `PURL_PARSER` (`PARSER_ID`))
 ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;

As you see PRIMARY KEY in the Parser_id and URL_MD5. When I try a simple select

EXPLAIN 
    SELECT   * 
    FROM  `PARSER_U_R_L` 
    WHERE `URL_MD5` IN ( ids )

In EXPLAIN of this select I have possible keys = Null.

What can be problem ?

1 Answer 1

1

The problem is that the URL_MD5 is not the first column in your primary key. Since you have an index with multiple columns, the optimizer won't use that index unless you supply a value for the first column as well.

If you supply a value for just the first column, the optimizer will use it, so try reversing the columns in the index.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.