Closed jdenquin closed 1 month ago
LIMIT 1 BY field
FINAL
GROUP BY
Usage :
# limit_by(<Integer>, <Symbol> or <String>) events = Event.limit_by(1, :event_key)
LIMIT BY
events = Events.limit_by(1, :event_key) sql = <<-SQL with events as (#{events.to_sql}) SELECT count() FROM events SQL Events.connection.select_value(sql)
limit_by(<Integer>, <[Symbol]> or <[String]>
@jdenquin please, fix conflicts
done!
LIMIT 1 BY field
clause is a very performant alternative for de-duplication. It's better than aFINAL
orGROUP BY
on large sets.Usage :
LIMIT BY
without grouping, if you want to do so, you should use CTE, eg:limit_by(<Integer>, <[Symbol]> or <[String]>