class PG::Result

The class to represent the query result tuples (rows). An instance of this class is created as the result of every query. All result rows and columns are stored in a memory block attached to the PG::Result object. Whenever a value is accessed it is casted to a Ruby object by the assigned type_map .

Since pg-1.1 the amount of memory in use by a PG::Result object is estimated and passed to ruby’s garbage collector. You can invoke the clear method to force deallocation of memory of the instance when finished with the result for better memory performance.

Example:

require 'pg'
conn = PG.connect(:dbname => 'test')
res  = conn.exec('SELECT 1 AS a, 2 AS b, NULL AS c')
res.getvalue(0,0) # '1'
res[0]['b']       # '2'
res[0]['c']       # nil