Module: Sequel::Plugins::ManyToOnePkLookup

Defined in:
lib/sequel/plugins/many_to_one_pk_lookup.rb

Overview

The ManyToOnePkLookup plugin that modifies the internal association loading logic for many_to_one associations to use a simple primary key lookup on the associated class, which is generally faster as it uses mostly static SQL. Additional, if the associated class is caching primary key lookups, you get the benefit of a cached lookup.

This plugin attempts to determine cases where the primary key lookup would have different results than the regular lookup, and use the regular lookup in that case. If you want to explicitly force whether or not to use primary key lookups for a given association, set the :many_to_one_pk_lookup association option.

Usage:

# Make all model subclass instances use primary key lookups for many_to_one
# association loading
Sequel::Model.plugin :many_to_one_pk_lookup

# Do so for just the album class.
Album.plugin :many_to_one_pk_lookup

Defined Under Namespace

Modules: ClassMethods, InstanceMethods