Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create new table with INT PK:

    Code Block
    sql
    CREATE TABLE mutationcore_logMutation_newLog (
      id BIGSERIAL PRIMARY KEY,
      uuid UUID NOT NULL UNIQUE,
      ... existing columns ...
    );
    
  2. Batch copy data (500k records/batch):

    Code Block
    sql
    INSERT INTO mutationcore_logMutation_newLog (uuid, json_content, ...)
    SELECT uuid, json_content, ... FROM mutation_log;
    
  3. Atomic switch during maintenance window:

    Code Block
    sql
    ALTER TABLE mutationcore_Mutation_logLog RENAME TO mutation_log_old;
    ALTER TABLE mutationcore_logMutation_newLog2 RENAME TO mutationcore_Mutation_logLog;
    

Performance Expectations

Metric

UUID (v4)

INT PK

Improvement

Insert Throughput

2.3k ops/s

4.1k ops/s

78% faster38

Index Size

12GB

3GB

75% smaller9

ORDER BY date LIMIT 100

420ms

23ms

18x faster9

Tip

The following strategy works for better performance.

...