Skip to content

feat: Store log data in a separate table#255

Merged
palkan merged 44 commits intomasterfrom
feat-log-data-separate-storage
Apr 9, 2025
Merged

feat: Store log data in a separate table#255
palkan merged 44 commits intomasterfrom
feat-log-data-separate-storage

Conversation

@Lokideos
Copy link
Collaborator

@Lokideos Lokideos commented Mar 17, 2025

What is the purpose of this pull request?

This PR addresses adds an option to store log_data in a separate table.

Context

The main concern of the logidze gem is performance. However, the current approach leads to table bloat. One of the ways to remediate this problem is to store log_data in a separate table, which is added in this PR.

What changes did you make? (overview)

  • Added an option to store log_data in a separate table. To achieve this:
    • Run bundle exec rails generate logidze:migration:logs to create a new table.
    • Run bundle exec rails generate logidze:model %MODEL_NAME% --detached to add needed helpers and trigger to the model.
    • Alternatively, you can set Logidze.log_data_placement configuration value to :detached to force storing all log_data in a separate table.
  • Added benchmarks for the new way of storing log_data.
  • Fixed issues with dummy setup in benchmarks.

Is there anything you'd like reviewers to focus on?

Checklist

  • I've added tests for this change
  • I've added a Changelog entry
  • I've updated a documentation (Readme)

@Lokideos Lokideos self-assigned this Mar 17, 2025
@Lokideos Lokideos force-pushed the feat-log-data-separate-storage branch from 121c76d to b372e90 Compare April 7, 2025 10:57
lib/logidze.rb Outdated
attr_reader :on_pending_upgrade
# Determines if we should treat all models as detached regardless of the +detached: true+ macros presence
# Usable for gem specs setup
attr_accessor :treat_models_as_detached
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call it log_data_placement = :detached | :inline

@Lokideos Lokideos force-pushed the feat-log-data-separate-storage branch from ac30fdd to 0bb4c06 Compare April 9, 2025 08:35
@Lokideos Lokideos force-pushed the feat-log-data-separate-storage branch from 880257c to f1600ad Compare April 9, 2025 08:51
@Lokideos Lokideos requested a review from palkan April 9, 2025 08:54
@palkan palkan marked this pull request as ready for review April 9, 2025 16:25
@palkan palkan merged commit dea13d4 into master Apr 9, 2025
17 checks passed
@palkan palkan deleted the feat-log-data-separate-storage branch April 9, 2025 21:59
@palkan
Copy link
Owner

palkan commented Apr 9, 2025

🚀

Thanks @Lokideos!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants