PDA

View Full Version : Iindex's (few simple questions)


VBAssassin
02-06-2006, 01:04 AM
Hello everyone,

Im kinda new to using index's but i understand that i must no at least the basics of them so i have been reading about them. Although the books and resources i have been using are quite detailed. They do not answer some simple questions i have!

1) If you create say 10 index's on a table, does MySQL automatically select the correct one? Or attempt to anyway?

2) What do each of the "primary", "index", "unique" and "fulltext" index types actually do? I no there index types but when should i use one and not the other and so on!

3) How would i go about creating an index on say a members table using phpMyAdmin, to speed up a query like the following?

SELECT `member_id` FROM `member_accounts` WHERE `username` LIKE 'VBAssassin' LIMIT 0 , 1

Thanks in advance :-)

Scott (VBAssassin)

VBAssassin
02-06-2006, 01:28 AM
# --------------------------------------------------------
#
# Table structure for table 'phpbb_banlist'
#
CREATE TABLE phpbb_banlist (
ban_id mediumint(8) UNSIGNED NOT NULL auto_increment,
ban_userid mediumint(8) NOT NULL,
ban_ip char(8) NOT NULL,
ban_email varchar(255),
PRIMARY KEY (ban_id),
KEY ban_ip_user_id (ban_ip, ban_userid)
);

what does KEY do exactly? when i search google it just tells me about primary keys!

VBAssassin
02-07-2006, 04:22 AM
never mind people, iv found the answers / worked them out using trial and error on a database i populated with 3million records using php to do the populating.