Jump to content

Recommended Posts

Hi,

i have some problem regarding mysql that i need help.

 

I have a member table that stores information of my user such as password,username,address,etc. Currently i have about 250k registered user(So thats 250k rows). The table has been running smoothly and querying to this table has been pretty fast. The table doesn't have an auto increment field before and i just assign the primary key to the username. Now, i need to add another auto increment field to it. But after i've done that, the database becomes significantly slower. Querying is super slow and sometimes when i try to browse the data from phpmyadmin, the database just hangs. As a result i have to restart the database.

 

This problem only occurs after i added the auto increment field. I am very sure. Because after i remove it, everything goes back to normal...

 

Can anyone help me here. I am really at a lost here....THANKS

 

Link to comment
https://forums.phpfreaks.com/topic/96416-really-need-help-on-this/
Share on other sites

this is the show create

[pre]

CREATE TABLE `member` (\n

`id` int(10) NOT NULL auto_increment,\n

`userid` varchar(50) NOT NULL default '',\n

`icnum` varchar(20) default NULL,\n

`gender` char(1) NOT NULL default '',\n

`birth` varchar(10) default NULL,\n

`entrydate` varchar(5) NOT NULL default '',\n

`name` varchar(40) NOT NULL default '',\n

`emailservice` char(1) NOT NULL default 'Y',\n

`regdate` varchar(10) NOT NULL default '',\n

`regip` varchar(15) NOT NULL default '',\n

`admin` char(1) default 'N',\n

`lastlogin` varchar(10) default NULL,\n

`lastloginip` varchar(15) NOT NULL default '',\n

`reset` char(1) NOT NULL default 'N',\n

`pwd` varchar(64) NOT NULL default '',\n

PRIMARY KEY (`id`),\n KEY `name` (`name`)\n

) ENGINE=MyISAM AUTO_INCREMENT=261189 DEFAULT CHARSET=latin1 PACK_KEYS=1 CHECKSUM=1 COMMENT='member'[/pre]

 

currently i only have an index for the name field...now that i've remove the primary key belonging to userid should i include an index for it?

currently i only have an index for the name field...now that i've remove the primary key belonging to userid should i include an index for it?

 

Definitely yes.

 

you could have kept it as the PK. The auto_inc field has to be a key but not necessarily the primary one.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.