https://github.com/afair/postgresql_cursor
ActiveRecord PostgreSQL Adapter extension for using a cursor to return a large result set - afair/postgresql_cursor
githubafairpostgresqlcursoractiverecord
https://www.elastic.co/blog/activerecord-to-repository-changing-persistence-patterns-with-the-elasticsearch-rails-gem
Learn how to easily move your Elasticsearch Rails app off of the deprecated ActiveRecord pattern and onto the Repository pattern with a step-by-step example....
with theactiverecordrepositorychangingpersistence