Hi.

On Tue, Mar 05, 2002 at 12:10:47PM -0700, [EMAIL PROTECTED] wrote:
[...]
> > Of course, MySQL has some kind of internal order depending on many
> > factors, but you may not rely on it. And neither you may rely on the
> > fact that a PRIMARY KEY influences the internal order. You have to use
> > an ORDER BY clause if you want to get a sorted result (of course, you
> > want a key to speed up the ORDER BY clause).
> 
> Hmmm.  Perhaps I'm misled by the default behaviour of other database engines,
> but I was taught that the primary key was stored in the database to optimize
> search/insert/delete - which meant *sorted*.  That is why you don't want a
> large (complex) primary key on tables that must run "fast" - the overhead of
> sorting each insert/delete negatively affects performance. Or so I was taught,
> anyway (back in the dark ages - primative data structures and all that <G>).
[...]

It seems that what you were taught was the internal working of
whatever database you were tought about. MySQL (with MyISAM tables)
definitely doesn't sort the data records according to the primary key. [1]

You loose a little bit of time on writing records, but only as much as
it needs to store a new leaf withi an B-Tree. That's not much.

Bye,

        Benjamin.


[1] But of course, you can explicitly sort the data of a MyISAM table
    with myisamchk resp. ALTER TABLE ... ORDER BY - but that's a
    different story and not the default

-- 
[EMAIL PROTECTED]

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to