Hi, I understand that. But paged_each is selecting whole table instead in 
batches. Maybe it's because I connect additional servers? Im fetching 
additional server`s database.

On Wednesday, March 14, 2018 at 4:49:10 PM UTC+2, Jeremy Evans wrote:
>
> On Wednesday, March 14, 2018 at 2:42:09 AM UTC-7, [email protected] 
> <javascript:> wrote:
>>
>> Hi,
>>
>> I have some troubles with Sequel`s paged_each.  I'm using mysql2 
>> I have simple model:
>>
>> class Attribute < Sequel::Model
>>   one_to_many :attribute_values
>> end
>>
>>
>> I'm connecting to slave database:
>> ...
>> DB = Sequel.connect(config, servers: servers)
>> ...
>>
>> rails console:
>>
>> irb(main):009:0> Attribute.methods
>> [... :paged_each, ...]
>>
>> irb(main):008:0> Attribute.paged_each
>> (0.001443s) SELECT * FROM `attributes` ORDER BY `id`
>>
>
> In the mysql2 adapter, if the mysql2 driver supports streaming, paged_each 
> uses streaming as an optimization by default.  If you really don't want to 
> use streaming for some reason, you can pass the :stream=>false option, but 
> in general there isn't a good reason to do that.
>
> The purpose of paged_each is to iterate over large result sets without 
> keeping all rows in memory.  The default implementation of paged_each uses 
> LIMIT/OFFSET since that should work on all databases.  paged_each can be 
> made to use ORDER BY and WHERE, which should also work on all databases.  
> However, if streaming results is supported, that's usually the fastest 
> approach and the default where it is supported.
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to