DamienHarper / auditor-bundle

The missing audit log library
MIT License
400 stars 121 forks source link

Use UUIDv4 for audit records PKs #346

Open kiler129 opened 1 year ago

kiler129 commented 1 year ago

On larger systems the auto increment causes a table lock, which decreases performance. With UUIDv4 primary keys the whole UoW can be built and then flushed without any back-and-forth to the database.

I'm guessing one of the challenges can be sorting. However, a precise microsecond time stamp could solve it easily.

WDYT about such an addition?

dmitryuk commented 1 year ago

@kiler129 Can you provide any article about this behavior in database? Anyway you should create primary key - unique index will be checked for every entry before inserting.

janklan commented 1 year ago

My two cents of thoughts are:

  1. If you use UUID6, you can use the ID to sort the data in time-related order
  2. On a large system, wouldn't it make sense to log the events asynchronously anyway?