{"repo":"afair/postgresql_cursor","free":true,"listed":false,"github":"https://github.com/afair/postgresql_cursor","clone":"git clone https://github.com/afair/postgresql_cursor.git","description":"ActiveRecord PostgreSQL Adapter extension for using a cursor to return a large result set","language":"Ruby","stars":651,"topics":["ruby","activerecord","cursor","large-scale","postgresql","postgresql-cursor","for-update","batch","ruby-gem"],"license":"MIT","category":"databases-storage","readme_excerpt":"PostgreSQLCursor for handling large Result Sets PostgreSQLCursor extends ActiveRecord to allow for efficient processing of queries returning a large number of rows, and allows you to sort your result set. In PostgreSQL, a cursor runs a query, from which you fetch a block of (say 1000) rows, process them, and continue fetching until the result set is exhausted. By fetching a smaller chunk of data, this reduces the amount of memory your application uses and prevents the potential crash of running out of memory. Supports Rails/ActiveRecord v3.1 (v3.2 recommended) higher (including v5.0) and Ruby 1.9 and higher. Not all features work in ActiveRecord v3.1. Support for this gem will only be for officially supported versions of ActiveRecord and Ruby; others can try older versions of the gem. Using Cursors PostgreSQLCursor was developed to take advantage of PostgreSQL's cursors. Cursors allow the program to declare a cursor to run a given query returning \"chunks\" of rows to the application program while retaining the position of the full result set in the database. This overcomes all the disadvantages of using find each and find in batches. Also, with PostgreSQL, you have on option to have raw hashes of the row returned instead of the instantiated models. An informal benchmark showed that returning instances is a factor of 4 times slower than returning hashes. If you are can work with the data in this form, you will find better performance. With PostgreSQL, you can work with cursors ","default_branch":null,"files":null,"tree":[],"storefront":"/r/afair","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/afair/postgresql_cursor/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}