I'm playing about with Drupal (a CMS) and looking through the database... This is the node table:
+----------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+------------------+------+-----+---------+----------------+
| nid | int(10) unsigned | | PRI | NULL | auto_increment |
| vid | int(10) unsigned | | PRI | 0 | |
| type | varchar(32) | | MUL | | |
| title | varchar(128) | | MUL | | |
| uid | int(10) | | MUL | 0 | |
| status | int(4) | | MUL | 1 | |
| created | int(11) | | MUL | 0 | |
| changed | int(11) | | MUL | 0 | |
| comment | int(2) | | | 0 | |
| promote | int(2) | | MUL | 0 | |
| moderate | int(2) | | MUL | 0 | |
| sticky | int(2) | | | 0 | |
+----------+------------------+------+-----+---------+----------------+
And this is the index description...
+-------+------------+---------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-------+------------+---------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| node | 0 | PRIMARY | 1 | nid | A | 10343 | NULL | NULL | | BTREE | |
| node | 0 | PRIMARY | 2 | vid | A | 10343 | NULL | NULL | | BTREE | |
| node | 0 | vid | 1 | vid | A | 10343 | NULL | NULL | | BTREE | |
| node | 1 | node_type | 1 | type | A | 1 | 4 | NULL | | BTREE | |
| node | 1 | node_title_type | 1 | title | A | 10343 | NULL | NULL | | BTREE | |
| node | 1 | node_title_type | 2 | type | A | 10343 | 4 | NULL | | BTREE | |
| node | 1 | status | 1 | status | A | 1 | NULL | NULL | | BTREE | |
| node | 1 | uid | 1 | uid | A | 1 | NULL | NULL | | BTREE | |
| node | 1 | node_moderate | 1 | moderate | A | 1 | NULL | NULL | | BTREE | |
| node | 1 | node_promote_status | 1 | promote | A | 1 | NULL | NULL | | BTREE | |
| node | 1 | node_promote_status | 2 | status | A | 1 | NULL | NULL | | BTREE | |
| node | 1 | node_created | 1 | created | A | 5171 | NULL | NULL | | BTREE | |
| node | 1 | node_changed | 1 | changed | A | 1 | NULL | NULL | | BTREE | |
| node | 1 | node_status_type | 1 | status | A | 1 | NULL | NULL | | BTREE | |
| node | 1 | node_status_type | 2 | type | A | 2 | NULL | NULL | | BTREE | |
| node | 1 | node_status_type | 3 | nid | A | 10343 | NULL | NULL | | BTREE | |
| node | 1 | nid | 1 | nid | A | 10343 | NULL | NULL | | BTREE | |
+-------+------------+---------------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
Now - phpMyAdmin is complaining about fields having multiple indexes on them.
My question is: "Is this a problem?"
Although it may be inneficient on space/storage, if this is not an issue (which is rarely is nowadays) does it cause any other problems?
I have this query:
SELECT n.nid, n.sticky, n.title, n.created
FROM node n
INNER JOIN category_node cn ON n.nid = cn.nid
WHERE cn.cid
IN ( 102, 120, 123, 175, 129, 118, 126, 122, 127, 121, 128, 124, 132, 131, 130, 133, 147, 140, 136, 135, 151, 137, 152, 142, 143, 148, 145, 134, 150, 149, 146, 218, 144, 139, 138, 141, 228, 160, 153, 166, 235, 155, 322, 159, 161, 167, 154, 162, 230, 156, 158, 163, 211, 165, 168, 169, 164, 172, 171, 173, 174, 331, 176, 178, 318, 201, 180, 177, 182, 185, 187, 184, 183, 188, 189, 194, 285, 323, 190, 198, 193, 170, 195, 196, 191, 202, 197, 192, 200, 205, 204, 199, 206, 207, 212, 209, 210, 208, 213, 221, 217, 214, 220, 219, 215, 216, 222, 223, 225, 224, 236, 226, 229, 232, 233, 234, 227, 237, 246, 238, 243, 242, 247, 240, 244, 245, 257, 253, 251, 265, 267, 264, 254, 262, 252, 259, 260, 263, 354, 266, 186, 250, 249, 256, 261, 248, 268, 255, 269, 278, 277, 275, 125, 279, 270, 281, 274, 271, 273, 280, 272, 258, 276, 282, 117, 288, 294, 283, 286, 295, 284, 287, 291, 289, 293, 292, 296, 297, 298, 299, 300, 203, 231, 239, 345, 352, 312, 316, 301, 313, 303, 311, 306, 310, 308, 302, 314, 356, 181, 241, 307, 290, 304, 315, 309, 320, 305, 157, 319, 335, 326, 336, 325, 324, 327, 330, 333, 329, 332, 328, 321, 334, 338, 337, 119, 339, 341, 342, 340, 317, 343, 350, 344, 346, 349, 347, 348, 351, 179, 353, 355, 358, 357, 359 )
AND n.status =1
AND n.moderate =0
GROUP BY n.nid, n.sticky, n.title, n.created
ORDER BY n.sticky DESC , n.created DESC
LIMIT 0 , 10
And it takes 0.4 seconds to run, which is pretty high for a MySQL Query. All fields seem to be indexed, but the n.nid field (for example) is indexed multiple times. Could this slow things down?
[center]