1
wizanda
Do you need PRIMARY KEY and not INDEX?
  • 2005/8/26 17:09

  • wizanda

  • Home away from home

  • Posts: 1585

  • Since: 2004/3/21


Ok I am trying to sort all these problems in the deep end of the pool before I can paddle.

Mysql website is so hard to follow

My question is this, when I have duplicate enteries for indexs, can i remove one?

Quote:
DROP PRIMARY KEY drops the primary index. (Prior to MySQL 4.1.2, if no primary index exists, DROP PRIMARY KEY drops the first UNIQUE index in the table. MySQL marks the first UNIQUE key as the PRIMARY KEY if no PRIMARY KEY was specified explicitly.)

If you add a UNIQUE INDEX or PRIMARY KEY to a table, it is stored before any non-unique index so that MySQL can detect duplicate keys as early as possible


I have on some and kept just the primary index and not the extra index and the modules still appers to work.

As if it specifies the same id, primary is still an index so my logic says you only need one index with the data, not 2, one primary and 1 index?

Yet which am I suposed to keep?

2
rowdie
Re: Do you need PRIMARY KEY and not INDEX?
  • 2005/8/26 17:37

  • rowdie

  • Just can't stay away

  • Posts: 846

  • Since: 2004/7/21


First things first. Are you talking about XOOPS core tables, or indexes you've created on your own tables? And if you're relying on PhpMyAdmin to tell you that you've got duplicate indexes, then don't trust it. It has a bug that incorrectly gives a warning, when in fact the index and primary key are NOT the same.

Correctly used indexes makes getting records from a database table quicker. Deleting the index normally won´t break anything (most of the time), but it can make record selection slower if your queries were designed to use the index.

Deleting a primary key is a very bad move.

What are you trying to achieve by deleting indexes and primary keys?

3
wizanda
Re: Do you need PRIMARY KEY and not INDEX?
  • 2005/8/26 18:23

  • wizanda

  • Home away from home

  • Posts: 1585

  • Since: 2004/3/21


Well I was trying to fix errors in xoops, as i have just lost my site from using 98% resources of the server.

2 years work gone like that!! They gave me no warning and then said do a fresh install, and if it is better you can have your site back.

As you are using to much resources, so I have spent the day trying to reduce errors on my home copy.

As you say phpadmin, says these are errors, as the index is used twice for the same id.

These are some of the XOOPS modules like randon quotes which has primary key =id and index =id

So I removed the index=id and it still works ok, as primary is also and index.

I am so stressed with it all

4
rowdie
Re: Do you need PRIMARY KEY and not INDEX?
  • 2005/8/26 18:34

  • rowdie

  • Just can't stay away

  • Posts: 846

  • Since: 2004/7/21


Indexes are not your problem. If anything, they would help use less resources, I'd say. Don't listen to phpMyAdmin about indexes, their warnings on indexes are rubbish.

Login

Who's Online

388 user(s) are online (124 user(s) are browsing Support Forums)


Members: 1


Guests: 387


oswaldo,

more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits