Displaying 20 results from an estimated 10000 matches similar to: ""Complex" Eager Loads"
2006 Nov 06
2
Eager Finder SQL
Hi, I just uploaded a Rails plugin that allows you to specify custom
SQL when doing a find with associations (AKA eager loading).
One of the problems I encountered when implementing the Chacha
Underground (http://underground.chacha.com) was being able to use
queries provided by the DBA to efficiently get all the informaion I
needed to render a page. In some cases, I needed to go two or three
2007 Aug 21
3
Eager Loading
is there a way to always eagerly load an associated object so that you
don''t have to put :include into every finder?
class Product <ActiveRecord::Base
belongs_to :user #always load user when product is loaded
end
Product.find(1).user.login
#1 query since user was loaded with the product, same as if i
used :include but I don''t want to have to specify it everywhere.
2006 Mar 31
2
Eager loading of polymorphic associations
Polymorphic associations work great until I try to do some eager
loading through :include. In my example, the interface name is
":imagehaver". Here''s my little eagerly loading find line:
Image.find(params[:id], :include => :imagehaver)
All it gives me is an ActiveRecord::EagerLoadPolymorphicError with no
further explanation. I haven''t been able to dig up anything
2006 Jan 19
0
Limited eager loads and conditions on the eager tables
Hi,
Why are limited eager loads and conditions on the eager tables incompatible?
Doing a find(:all) without :include causes a select * query to be generated,
which means the id fields everwrite each other if associated tables are
included using :joins.
But using :include, if conditions are placed on the tables listed in :joins
then Rails throws an exception when :limit is included too.
2006 Jan 06
2
How do I reference eagerly loaded Models in the View?
[I hope the repost isnt'' "minded". Following the advice of another
thread I''ve changed the subject to a question. If I haven''t included
important info, please ask. My database is being unduly killed. Jodi]
Cheers on-the-Rails-ers,
Before I start, I''ve read the ActiveRecord docs on eager loading, but
for the life of me, I can''t seem to get
2006 Oct 08
1
Two-way eager loading?
My problem is that I have two classes where the eager loading isn''t
working as well as I would hope...
Here are my two classes:
class Daynote < ActiveRecord::Base
belongs_to :userplace
class Userplace < ActiveRecord::Base
has_many :daynote, :dependent => true
When I show my userplaces, I want to get the associated daynotes with
them, so I am doing:
@userplace =
2006 Jul 24
3
HowTo?: Eager caching of third order ActiveRecord assoc.
Hello.
Using the ":include", which generates a "LEFT OUTER JOIN" SQL command,
it is possible to eagerly preload second order data objects (children)
for a given association.
I wanted to know, if it is possible to eagerly preload and cache
third order (or more) data objects, which are little-children or
little-little-children. As I''ve seen. it is possible to add
2010 Oct 25
1
A few fixes to eager loading issues
Hey all,
I''d really appreciate some eyes on https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5845-activerecord-3-eager-loading-fail#ticket-5845-19. There''s a small issue in Rails 3 eager loading, and this ticket has an accompanying patch.
Sssociations that show up twice in a Relation chain like:
Article.includes(:comments).includes(:comments =>
2008 May 08
1
Eager loading of association extensions
Hello all,
Is it possible to do eager loading of association extensions?
That is, the following code produces one SQL query:
cat = ProductCategory.find(:first, :include => :pricing_rules)
cat.pricing_rules
But if in ProductCategory I have an association extension like this:
has_many :pricing_rules do
def applicable()
find(:all).select(&:applicable?)
end
end
the
2007 Apr 26
1
eager loading not working in production mode
i have an eager load query as such:
@groups = ReviewQuestionGroup.find(:all,
:conditions => ["review_category_id = ?", @review.category.id],
:order => ''review_question_groups.position,
review_questions.position'',
:include => :questions)
in dev mode, this works fine... i get results like
@groups[0].questions.length = 13. in production, i
2010 Aug 05
3
how to ? Rails 3 ActiveRecord eager loading and AREL
Hello everyone,
I would like to eager load scoped records to avoid queries executed in a
loop (huge performance impact).
The "scoped" part is what is giving me a hard time.
I''m using Rails3 RC.
Does anyone have any idea how I can do it?
Here is a test case : we have an "Article" and a "Comment" Activerecord
models,
article has many comments
comment
2009 Oct 08
6
Eager Loading a Relationship That Has No PK/FK
I''m attempting to wrestle an old DB into Rails.
This relationship is giving me trouble:
class Show < AR::Base
has_many :segments
end
class Segment < AR::Base
belongs_to :show
has_one :media #this has no PK/FK relation
end
A Segment is "linked" to Media by Media.name, which is the result of
concatenating Segment.name and Segment.part. As I said there are is no
2011 Dec 06
1
unserialize and eager execution
Hi,
While debugging a network server I'm developing I noticed something unusual
- call to unserialize() resulted in
an error about loading a namespace.
I was a bit taken back by this - why should unserializing an object cause a
namespace lookup?
Are there any other side-effects of unserialize() that I should be cautious
about? I've been
digging through the R_Unserialize() call, I
2006 Jun 28
4
Load IDs For Limited Eager Loading
Hi
Trying to cut down on queries with eager loading and noticed the
following in development.log
Load IDs For Limited Eager Loading - SELECT id ....etc
Followed by
Load Including Associations - SELECT table.id ... etc
Is this common practice? What is limted eager loading?
Cheers
Mark
--
Posted via http://www.ruby-forum.com/.
2006 Sep 13
1
Eager loading with acts_as_tree
So I have a model that acts_as_tree and I run a method on a collection
of all of these records. This method walks the tree and fetches the
parent/children, etc. This results in many, many duplicate SQL queries
to be executed. Is there a way to eagerly load all of these models?
Something along the lines of:
Model.find(:all, :include => [:children, :parent])
If I execute the above statement, I
2006 Jan 31
4
Rails bug? Conditions on associations ignored by eager loading
I''m looking for someone to confirm the following as a bug in Rails
1.0 before I post it to Trac.
If I use eager loading on an association that has conditions defined,
the conditions are ignored.
The following example illustrates the problem. I have two tables:
create_table "blogs", :force => true do |t|
t.column "name", :string
end
create_table
2005 Jul 26
6
eager associations and limit/offset
Hi,
currently the eager association loading via ":include" does not work
when a has-many or habtm association is combined with offset/limit
(which is required for paginations). This is because in these cases, the
result set will contain more than one row per object, but limit/offset
works on row numbers.
I''ve developed a patch that makes this work by using 2 SQL statements
2006 Aug 16
1
using :select with :include to limit eager loading
Activerecord''s find option `:select'' does not appear to work when
:include is used to eager load associations. However, I sometimes want
to perform ready-made joins on associations to limit the results of a
query. here''s a simple example:
table university:
STRING code
INT id
table term:
STRING name
INT university_id
INT id
the associations of the models
2008 Jan 04
1
eager loading and polymorphic associations
There is a dedicated section about eager loading in the docs. A
coworker discovered eager loading does not work in polymorphic
associations the hard way :-) so I''ve written a patch that documents it:
http://dev.rubyonrails.org/ticket/10610
There are at least a couple of tickets that implement something that
would change that though:
http://dev.rubyonrails.org/ticket/9640
2007 Nov 08
0
Dynamic relation with eager loading
A model has 2 columns in its table
asset_type_id
asset_id
the asset_type_id links directly to the table asset_types via a
belongs_to
asset_types contains a single column ''name''
method_missing in the model says when you call a method matching
/^asset.*/
call the corresponding method substituting ''asset'' for the contents of
asset_type.name
(ie. the name in