Permalink
Browse files

Include streaming file in the gem, and update README

  • Loading branch information...
1 parent a625e03 commit 93015b770fb4f6792df3da40eed8e944db4dfe44 @jeremyevans committed May 21, 2012
Showing with 34 additions and 8 deletions.
  1. +33 −7 README.rdoc
  2. +1 −1 sequel_pg.gemspec
View
@@ -38,13 +38,13 @@ Here's an example that uses a modified version of swift's benchmarks
sequel #select 0.090000 2.020000 2.110000 2.246688 46.54m
sequel_pg #select 0.000000 0.250000 0.250000 0.361999 7.33m
-sequel_pg also has code to speed up the map, to_hash, select_hash,
-select_map, and select_order_map Dataset methods, which is on by
-default. It also has code to speed up the loading of model objects,
-which is off by default as it isn't fully compatible. It doesn't
-handle overriding Model.call, Model#set_values, or
-Model#after_initialize, which may cause problems with the
-following plugins that ship with Sequel:
+sequel_pg also has code to speed up the map, to_hash, to_hash_groups,
+select_hash, select_hash_groups, select_map, and select_order_map
+Dataset methods, which is on by default. It also has code to speed
+up the loading of model objects, which is off by default as it isn't
+fully compatible. It doesn't handle overriding Model.call,
+Model#set_values, or Model#after_initialize, which may cause problems
+with the following plugins that ship with Sequel:
* class_table_inheritance
* force_encoding
@@ -63,6 +63,32 @@ enable the model optimization via:
# Specific dataset
Artist.dataset.optimize_model_load = true
+== Streaming
+
+If you are using PostgreSQL 9.2 or higher on the client, then sequel_pg
+should enable streaming support. This allows you to stream returned
+rows one at a time, instead of collecting the entire result set in
+memory (which is how PostgreSQL works by default). You can check
+if streaming is supported by:
+
+ Sequel::Postgres.supports_streaming?
+
+If streaming is supported, you can load the streaming support into the
+database:
+
+ require 'sequel_pg/streaming'
+ DB.extend Sequel::Postgres::Streaming
+
+Then you can call the Dataset#stream method to have the dataset use
+the streaming support:
+
+ DB[:table].stream.each{|row| ...}
+
+If you want to enable streaming for all of a database's datasets, you
+can do the following:
+
+ DB.extend_datasets Sequel::Postgres::Streaming::AllQueries
+
== Installing the gem
gem install sequel_pg
View
@@ -10,7 +10,7 @@ SEQUEL_PG_GEMSPEC = Gem::Specification.new do |s|
s.email = "code@jeremyevans.net"
s.homepage = "http://github.com/jeremyevans/sequel_pg"
s.required_ruby_version = ">= 1.8.7"
- s.files = %w(MIT-LICENSE CHANGELOG README.rdoc Rakefile ext/sequel_pg/extconf.rb ext/sequel_pg/sequel_pg.c lib/sequel_pg/sequel_pg.rb)
+ s.files = %w(MIT-LICENSE CHANGELOG README.rdoc Rakefile ext/sequel_pg/extconf.rb ext/sequel_pg/sequel_pg.c lib/sequel_pg/sequel_pg.rb lib/sequel_pg/streaming.rb)
s.extensions << 'ext/sequel_pg/extconf.rb'
s.add_dependency("pg", [">= 0.8.0"])
s.add_dependency("sequel", [">= 3.34.0"])

0 comments on commit 93015b7

Please sign in to comment.