Skip to content

Commit

Permalink
add notes
Browse files Browse the repository at this point in the history
  • Loading branch information
jdenquin committed Oct 8, 2024
1 parent eb112d9 commit 283d9d5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/core_extensions/active_record/relation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,19 @@ def window!(name, **opts)
self
end

# The LIMIT BY clause permit to improve deduplication based on a unique key, it has better performances than
# the GROUP BY clause
#
# users = User.limit_by(1, id)
# # SELECT users.* FROM users LIMIT 1 BY id
#
# An <tt>ActiveRecord::ActiveRecordError</tt> will be reaised if database is not Clickhouse.
# @param [Array] opts
def limit_by(*opts)
spawn.limit_by!(*opts)
end

# @param [Array] opts
def limit_by!(*opts)
@values[:limit_by] = *opts
self
Expand Down

0 comments on commit 283d9d5

Please sign in to comment.