help with indexing

Codes here !

Moderators: egami, macek, gesf

Post Reply
NigelRen
php-forum Fan User
php-forum Fan User
Posts: 622
Joined: Fri Aug 05, 2011 9:53 am

Mon Aug 06, 2012 12:07 am

Do you have a table structure - preferably SQL?
Also you say 'selected index as the index' which I'm not sure what you mean by this? Are you using phpmyadmin or some other database tool?
What fields do you need to be indexed?

User avatar
freshnet
php-forum Active User
php-forum Active User
Posts: 359
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada

Mon Aug 06, 2012 4:06 am

the primary key value for your table is a value that's used to identify the row. That one should have the primary index, and only one of those is allowed per table.
If you have some other data in your table that's unique (for example a character name or in-game id number) you can also use a unique index for that. A unique index will give an error if you try to insert a duplicate value.
For all other information, you can use a regular index. It's generally only worth indexing columns that you will be using a lot, so if you're looking up things by a number such as health, index that.

In general though, with a mysql database the performance improvement you'll see with indexing will be very small until the database tables get quite large (e.g. around 1 million rows).

johnj
php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Tue Aug 07, 2012 5:52 am

There is a limit on the number of key parts that can be specified. I am not sure if we can override this - You need to ask this question on the mysql forum.

User avatar
freshnet
php-forum Active User
php-forum Active User
Posts: 359
Joined: Tue Feb 22, 2011 8:19 am
Location: Canada

Tue Aug 07, 2012 10:43 am

For your needs I don't see why you'd need a multi-part index. Since these are all separate statistics, I'm guessing you'd be querying many of them separately. If not, just index the few most commonly queried columns together. A multi-column index is slightly faster than a single column, but again unless your tables are into the millions of rows, you probably won't see any difference.

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests