Skip to content

Commit

Permalink
Return arrays of common data types as PGArray instances automatically…
Browse files Browse the repository at this point in the history
… with much improved performance

This modifies the array parser to accept an oid and dataset in
addition to the conversion proc.  If the oid is set, this uses
similar logic as the default type conversion code for converting
each array element.

The default type conversion code now recognizes arrays of common
types and now calls the array parser directly with the scalar
type oid set, so that the entire array can be parsed without
creating a ruby string for it (though a ruby string is still
created for the per-element buffer).

This improves performance about 10% for string arrays, 3x for
integer arrays, and 5-6x for timestamp arrays.

Array types are now returned as PGArray instances, and sequel_pg
now loads the pg_array extension file to support that.  However,
the pg_array extension should still be loaded into the Database
manually if you want to handle custom array types, arrays as
bound variable arguments, and other more advanced features.

This also exposes the SEQUEL_PG_VERSION_INTEGER to ruby, as
Sequel may need to check this to determine the sequel_pg version
to allow for version-specific behavior.
  • Loading branch information
jeremyevans committed Jun 6, 2018
1 parent 7471169 commit ebd149e
Show file tree
Hide file tree
Showing 2 changed files with 316 additions and 32 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
=== master

* Return arrays of common data types as PGArray instances automatically with much improved performance (jeremyevans)

* Borrow pg_text_dec_integer function from ruby-pg and use it to improve performance (jeremyevans)

* Borrow PG_ENCODING_SET_NOCHECK macro from ruby-pg and use it to improve performance (jeremyevans)
Expand Down
Loading

0 comments on commit ebd149e

Please sign in to comment.