The sequel_pg extension provides optimizations for Sequel::Model instance creation and dataset iteration. When using a Sequel::Postgres::Dataset, the each method is automatically intercepted to use an optimized path if certain conditions are met.
To trigger the optimized model load, the following conditions must be satisfied:
- The
row_proc must be a Sequel::Model class. - The
row_proc must not be a 'graphed' dataset (it must not use eager_graph or similar). - The dataset must not be using a cursor.
- The
row_proc must not have shape_friendly set to true (if Sequel::Model.respond_to?(:shape_friendly) is available). - The
row_proc's call method must be owned by Sequel::Model::ClassMethods. - The dataset option
:optimize_model_load must not be explicitly set to false.
If these conditions are met, each will use fetch_rows with internal flags (:_sequel_pg_type=>:model) to bypass standard row processing in favor of the optimized version.