Closed (won't fix)
Project:
Drupal core
Version:
6.x-dev
Component:
profile.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
9 Feb 2009 at 11:37 UTC
Updated:
20 Feb 2009 at 05:36 UTC
The query
SELECT f.name, f.type, v.value FROM profile_fields f INNER JOIN profile_values v ON f.fid = v.fid WHERE uid = %d;
doesn't use the indices on D6.
This is the tablel structure on D6:
CREATE TABLE `profile_values` (
`fid` int(10) unsigned NOT NULL default '0',
`uid` int(10) unsigned NOT NULL default '0',
`value` text,
PRIMARY KEY (`uid`,`fid`),
KEY `fid` (`fid`)
)
and this on D5:
CREATE TABLE `profile_values` (
`fid` int(11) unsigned default '0',
`uid` int(11) unsigned default '0',
`value` text,
KEY `uid` (`uid`),
KEY `fid` (`fid`)
)
The mixed primary index does apparently not work:
mysql> explain SELECT f.name, f.type, v.value FROM profile_fields f INNER JOIN profile_values v ON f.fid = v.fid WHERE v.uid = 12345;
+----+-------------+-------+--------+---------------+---------+---------+---------------------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+--------+---------------+---------+---------+---------------------+------+-------------+
| 1 | SIMPLE | f | ALL | PRIMARY | NULL | NULL | NULL | 28 | |
| 1 | SIMPLE | v | eq_ref | PRIMARY,fid | PRIMARY | 8 | const,drupal6.f.fid | 1 | Using where |
+----+-------------+-------+--------+---------------+---------+---------+---------------------+------+-------------+
Comments
Comment #1
gábor hojtsyComment #2
david straussYou are incorrect. Your example explicitly shows MySQL using the new primary key:
| 1 | SIMPLE | v | eq_ref | PRIMARY,fid | PRIMARY | 8 | const,drupal6.f.fid | 1 | Using where |For table "v" (profile_values), it's using key PRIMARY. It's not using a key on the profile_fields table. While MySQL could use PRIMARY for profile_fields (and says as much), it's joining on practically the whole table, so it's correctly deciding to not use the key.
Comment #2.0
david straussadded code tags