sambar
01-03-2007, 12:28 PM
I don't know, but have I got the wrong idea about indexing? I'm stuck..
I have to fields in my table:
`player_1` mediumint(7) unsigned NOT NULL default '0'
`player_2` mediumint(7) unsigned NOT NULL default '0'
reffering to users' id-number in another table.
I have two indexes:
KEY `one` (`player_1`),
KEY `two` (`player_2`)
The cardinality of them is 6000 and 7000. My primary-key has cardinality 150 000.
When i run this query:
EXPLAIN SELECT *
FROM `gamebase`
WHERE player_1 =1
It uses the "one"-key (doh!).
But now, that I run my next query (using OR), it tells me that one and two are possible keys, but it uses neither, but loops through my entire table "Using where".
EXPLAIN SELECT *
FROM `gamebase`
WHERE player_1 =1
OR player_2 =1
What am I doing wrong or not understanding?
Thanks for your time.
I have to fields in my table:
`player_1` mediumint(7) unsigned NOT NULL default '0'
`player_2` mediumint(7) unsigned NOT NULL default '0'
reffering to users' id-number in another table.
I have two indexes:
KEY `one` (`player_1`),
KEY `two` (`player_2`)
The cardinality of them is 6000 and 7000. My primary-key has cardinality 150 000.
When i run this query:
EXPLAIN SELECT *
FROM `gamebase`
WHERE player_1 =1
It uses the "one"-key (doh!).
But now, that I run my next query (using OR), it tells me that one and two are possible keys, but it uses neither, but loops through my entire table "Using where".
EXPLAIN SELECT *
FROM `gamebase`
WHERE player_1 =1
OR player_2 =1
What am I doing wrong or not understanding?
Thanks for your time.