Quantcast
Channel: MySQL Forums - InnoDB
Viewing all articles
Browse latest Browse all 1954

Can two single-keys be used instead of a multi-key? (2 replies)

$
0
0
Hi, I have a table storing user IDs and the times those users did a certain thing. Sometimes we want to know what a user did in a certain time period, so we add a multi-key to the table:
Quote:
KEY `uid` (`uid`,`start`)
So this can be done efficiently: SELECT * FROM t WHERE uid='...' AND start BETWEEN '...' AND '...';

From time to time we'd like to delete older entries irregardless of which user they belong to, so a second key comes along (because the second column of the multi-key above cannot be used alone):
Quote:
KEY `start` (`start`)
So this can be done efficiently: DELETE FROM t WHERE start<'...';

Can the same same two queries be index-optimized with two one-column keys? Something like:
Quote:
KEY `uid` (`uid`),
KEY `start` (`start`)

Thanks.

Viewing all articles
Browse latest Browse all 1954

Trending Articles