#178 No unique keys in log table

Database (41)

There are no keys defined for the log table, which can make it difficult to manage the data on busier servers where it's just not possible to get even a unique composite key.

Two solutions occur to me:
1. Add an autoincremented INT or BIGINT column for a unique ID on each record.
2. Incorporate microtime information into the timestamp, or a separate column

The first method would be easiest, as it only requires adding a column. The second is more efficient though as the microtime could be stored in something as small as an UNSIGNED MEDIUMINT, and you never have to worry about running out of AUTOINCREMENT space.

The caveat to approach #2 would be that log entries prior to the version incorporating this change would have to be discarded as updating all entries prior with new values unique enough to compute a key would be an exercise in tedium. ie. modifying log entries made in the same second to have different microtime values.


  • Christian Boltz

    Christian Boltz - 2011-04-23
    • summary: No keys in log table --> No unique keys in log table
  • Christian Boltz

    Christian Boltz - 2011-04-23

    (sorry for the late reaction!)

    I know that the log table does not have an UNIQUE key, however I don't see why it would need one ;-)
    Our only usage of the log table is to display the most recent entries per domain, sorted by timestamp - and this works fine without an UNIQUE key.

    Is there a special reason why you think we should add an UNIQUE key like an autoincrement? (BTW: I won't use microtime as unique key - according to Murphy, there will be conflicts ;-)

    BTW: I just added an index on the domain and timestamp column (SVN trunk r1050) to speedup logview.


Log in to post a comment.