forest_admin_agent 1.46.2 → 1.46.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66c2c677df8cd9ee2cdb91925ea87a84e7d7b949d5ebf2f57104de3591e1df24
4
- data.tar.gz: 8a844fc3354a9e522f04038e6f966252370650980035e1ad59763a0a91d74331
3
+ metadata.gz: e52d3d37dd23fa657a733dad796c988c7a6d070d39f2bcea2fe8da884e5ed791
4
+ data.tar.gz: ab75a027751a703bda3a35a2b8c6cba046552da3b9511a379fce304274297a2c
5
5
  SHA512:
6
- metadata.gz: f1c7ffe69debc653eeec2013f3038e61a16119c78d18930851e8a2d45b09c32ebb4378843295c38fb05d2b3d6d779e1a9ab65f76decd08a587c41ee91ef1a46e
7
- data.tar.gz: 42b9d25705b3695cdeb9858026362f5732df3f54433afec6e17fd351615411cd8fa98bec3129e101ab1df5595e3c87f6d5c78297a3130387f35b7deab356033d
6
+ metadata.gz: 01e14b5c1410e354d7e8101a1d4a584f7ce453d23c34260c946c5a74a6b5c298d4184c7c6cb6889c1e862a3247ac39229e905b12825bcbd17ed07d13febbac3f
7
+ data.tar.gz: 73c1c0b3d9093a9b75c267b5786f74533907ab0c52602e1809d82bc3cfda2497f87fa524daf4cee76e0f1b73eeccd724318b516831ca5dc7c18750bebaae1ee1
@@ -62,6 +62,27 @@ module ForestAdminAgent
62
62
  connection.add_index(table, %i[timestamp id], name: "#{table.split(".").last}_timestamp_id",
63
63
  if_not_exists: true)
64
64
  end
65
+ },
66
+ {
67
+ # A record's history is read by (collection, record_id) in (timestamp, id) order. With only
68
+ # `record_id` and `(timestamp, id)` to choose from, Postgres either reads every row the id holds
69
+ # across all collections, or walks the whole table's (timestamp, id) index under a LIMIT: the life
70
+ # boundary lookup discarded 2.1M rows (486 ms) on a 2.1M-row table for a record created long ago.
71
+ name: '004-index-record-history',
72
+ up: lambda do |connection, table|
73
+ base = table.split('.').last
74
+ columns = %i[collection record_id timestamp id]
75
+ options = { if_not_exists: true }
76
+ options[:length] = { record_id: 255 } if connection.adapter_name.downcase.match?(/mysql|maria/)
77
+
78
+ connection.add_index(table, columns, name: "#{base}_record_history", **options)
79
+ next unless connection.supports_partial_index?
80
+
81
+ # The life boundary keeps a record's `create` and `delete` rows only: without this, a record
82
+ # updated 100k times is read whole to find its one `create`.
83
+ connection.add_index(table, columns, name: "#{base}_life_boundaries",
84
+ where: "operation IN ('create', 'delete')", **options)
85
+ end
65
86
  }
66
87
  ].freeze
67
88
  end
@@ -204,11 +204,12 @@ module ForestAdminAgent
204
204
  .uniq { |author| author[:user_id] }
205
205
  end
206
206
 
207
- # Rows strictly before `row` in the trail's (timestamp, id) order.
207
+ # Rows strictly before `row` in the trail's (timestamp, id) order. A row value rather than the equivalent
208
+ # `timestamp < ? OR (timestamp = ? AND id < ?)`, which Postgres cannot turn into a range on the
209
+ # (collection, record_id, timestamp, id) index: on a 50k-row history the OR read all of it (7 ms), the row
210
+ # value a single entry (0.06 ms).
208
211
  def before_row_condition(row)
209
- at = as_time(row.timestamp)
210
-
211
- ['timestamp < ? OR (timestamp = ? AND id < ?)', at, at, row.id]
212
+ ['(timestamp, id) < (?, ?)', as_time(row.timestamp), row.id]
212
213
  end
213
214
 
214
215
  # Rows strictly past `row` in the history's own order, so a scan keyed on the last row it read neither
@@ -6,7 +6,7 @@ module ForestAdminAgent
6
6
  module Schema
7
7
  class SchemaEmitter
8
8
  LIANA_NAME = "agent-ruby"
9
- LIANA_VERSION = "1.46.2"
9
+ LIANA_VERSION = "1.46.3"
10
10
 
11
11
  def self.generate(datasource)
12
12
  datasource.collections
@@ -1,3 +1,3 @@
1
1
  module ForestAdminAgent
2
- VERSION = "1.46.2"
2
+ VERSION = "1.46.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_admin_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.46.2
4
+ version: 1.46.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthieu
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2026-10-20 00:00:00.000000000 Z
12
+ date: 2026-10-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord