I have a drupal user table:

+------------------+------------------+------+-----+---------+----------------+
| Field            | Type             | Null | Key | Default | Extra          |
+------------------+------------------+------+-----+---------+----------------+
| uid              | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| name             | varchar(60)      | NO   | UNI |         |                |
| pass             | varchar(32)      | NO   |     |         |                |
| mail             | varchar(64)      | YES  | MUL |         |                |
| mode             | tinyint(4)       | NO   |     | 0       |                |
| sort             | tinyint(4)       | YES  |     | 0       |                |
| threshold        | tinyint(4)       | YES  |     | 0       |                |
| theme            | varchar(255)     | NO   |     |         |                |
| signature        | varchar(255)     | NO   |     |         |                |
| created          | int(11)          | NO   | MUL | 0       |                |
| access           | int(11)          | NO   | MUL | 0       |                |
| login            | int(11)          | NO   |     | 0       |                |
| status           | tinyint(4)       | NO   |     | 0       |                |
| timezone         | varchar(8)       | YES  |     | NULL    |                |
| language         | varchar(12)      | NO   |     |         |                |
| picture          | varchar(255)     | NO   |     |         |                |
| init             | varchar(64)      | YES  |     |         |                |
| data             | longtext         | YES  |     | NULL    |                |
| signature_format | smallint(6)      | NO   |     | 0       |                |
+------------------+------------------+------+-----+---------+----------------+
19 rows in set (0.09 sec)

I'm doing a lot of SELECT uid FROM users WHERE name='dave';

Does it make sense to create the new table:

+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| uid   | int(10)     | NO   | PRI | NULL    |       |
| name  | varchar(64) | NO   |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
2 rows in set (0.09 sec)

Are there any benefits?

I do not see any benefit creating another table,
First you are retrieving a specific value without any join or combined statement. In the other hand you right if you retrieve smaller record you have better efficiency, but the question is, is it worth the difference between the retrieving time? in this specific case I bet you not, besides creating another table is going to add another procedure to maintain two tables at the same time.

Regards.

Thanks for that. Roughly what I had thought.

anytime, take care.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.