Roger Baklund wrote:
> However, if the behaviour with no restrictions on duplicates is 
> correct, you may be better of without a primary key in this case.

  Okay, that's what I need here.

> Also, the second create statement defines indexes on all fields, making
> almost any query reasonably fast.

  That's what I need here, too.

> You can almost always improve the performance of queries by adding an 
> index. The trick is to add the right index... :) If you for instance 
> often did a "SELECT * FROM pot_accesslog WHERE client_id=$id AND 
> timestamp > NOW() - INTERVAL 24 HOUR", you could add an index with 
> the involved fields: KEY client_time (client_id,timestamp).

  Would this perform different from a situation where I have separate
  indexes on both columns?

> You should not create too many indexes, though. Inserts, updates and 
> deletes are slower when you have more indexes. You need to find 
> indexes that may be used by different queries: the client_time 
> (client_id,timestamp) index can also be used when you have a 
> client_id, but not the timestamp. This is because client_id is the 
> first part of the index.

  I know, therefore I use DELAY_KEY_WRITE=1. (Thanks to David & Kaj for
  pointing this out to me during lunch at the PHP International Conf)

> CREATE TABLE pot_add_data (
>   accesslog_id int(10)      unsigned NOT NULL,
>   data_field   varchar(32)           NOT NULL,
>   data_value   varchar(255)          NOT NULL,
>
>   PRIMARY KEY    (accesslog_id),
>   KEY data_field (data_field),
>   KEY data_value (data_value)
> );
>
> Very often it is better to define this last index like this:
>
>   KEY data_value (data_value(20))

  I know, this was a leftover. I do not need that index at all and
  dropped it already.

> I hope the above suggestions was usefull :)

  Thanks for your help,
Sebastian

-- 
  Sebastian Bergmann
  http://sebastian-bergmann.de/                 http://phpOpenTracker.de/

  Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/

---------------------------------------------------------------------
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