Skip to content

Conversation

@BuonOmo
Copy link
Collaborator

@BuonOmo BuonOmo commented Oct 9, 2025

TODOs:

  • publish the new rgeo-activerecord 8.1 compatible gem (see bump to 8.1 rgeo/rgeo-activerecord#84)
  • verify that the new implemetation of #foreign_keys works if t2 doesn't belong to the same namespace as t1

@BuonOmo BuonOmo force-pushed the feat/rails-8-1 branch 2 times, most recently from cb4869f to d8e3e07 Compare October 9, 2025 11:36
Rails is moving towards ractor compatibility, and to
do so it swapped to frozen database objects. Hence
we cannot simply memoize the factories anymore. I've
checked the initialization speed for factories, and
the memoization was too fast for it to be worth
implementing a cache.

See rails/rails@d2da816
See rails/rails@76448a0
- update some outdated overrides.
- update override comments to know when
  was the last override.
- remove the `#column_names_from_column_numbers`
  method that was generating N+1 queries.
- update related methods.

See:
- rails/rails@249c367
- rails/rails@4e0546c
- rails/rails@c93d1b0
#
# @see: https://github.com/rails/rails/blob/8695b028261bdd244e254993255c6641bdbc17a5/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb#L829
# OVERRIDE(v8.1.1):
# - comment is retrieved differently than PG for performance
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

col_description is the method used to retrieve the comment in PG. @rafiss is still true that this is slower than using information_schema.columns ?

Comment on lines +38 to +42
ARRAY(
SELECT a.attname
FROM pg_attribute a
WHERE a.attrelid = d.indexrelid AND a.attishidden
) AS hidden_columns
Copy link
Collaborator Author

@BuonOmo BuonOmo Oct 30, 2025

Choose a reason for hiding this comment

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

@rafiss
I added this bit. I'm really unsure about performances, any better idea would be appreciated.

The goal is to remove hidden columns from the columns above. My main issue was that we are using pg_get_indexdef to retrieve the columns. I don't know edge cases so I was not eager to use another method, but if we were not to use it I feel like we could easily have a faster and simpler approach.

My second question is: do you have a simple routine to benchmark two slightly different columns in CRDB, and pitfalls I should avoid?


EDIT: one of the ideas I had:

ARRAY(
  SELECT a.attname
  FROM pg_attribute a
  JOIN unnest(d.indkey) AS k(attnum)
  ON a.attrelid = d.indrelid AND a.attnum = k.attnum
  AND NOT a.attishidden
) AS visible_columns

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant