Axel Richter: MySQL: Warum 8.76 Sekunden?

Beitrag lesen

Hallo,

aber: sind auf den verknüpfungen indizees drauf?
Wow, das wirkte ja Wunder!

*g* Ja, nicht? Das ist genau das, wofür ein Index da ist ;-)).

Gell, die Primary-Key Spalte wird bei MySQL automatisch indexiert man muss dort drauf nicht noch extra einen Index anlegen. Oder?

Ja, PRIMARY-KEY ist einfach eine Kombination von UNIQUE und NOT NULL.
http://dev.mysql.com/doc/mysql/en/create-table.html
...
KEY is normally a synonym for INDEX. From MySQL 4.1, the key attribute PRIMARY KEY can also be specified as just KEY when given in a column definition. This was implemented for compatibility with other database systems.

In MySQL, a UNIQUE index is one in which all values in the index must be distinct. An error occurs if you try to add a new row with a key that matches an existing row. The exception to this is that if a column in the index is allowed to contain NULL values, it can contain multiple NULL values. This exception does not apply to BDB tables, for which an indexed column allows only a single NULL.

A PRIMARY KEY is a unique KEY where all key columns must be defined as NOT NULL. If they are not explicitly declared as NOT NULL, MySQL declares them so implicitly (and silently). A table can have only one PRIMARY KEY. If you don't have a PRIMARY KEY and an application asks for the PRIMARY KEY in your tables, MySQL returns the first UNIQUE index that has no NULL columns as the PRIMARY KEY.
...

viele Grüße

Axel