Hey there.. I''m in the process of demoing RoR as a viable framework for use on a large web app we''re building. One of the views I''ll want to create is a join of about 5 tables, presented in a long list, thousands of rows perhaps. I''m wondering the best way to go about this? Ideally I wouldn''t be creating a view in the DB for every such screen I want to create (kind of defies the MVC idea).. but is there an elegant way to do this in Rails? Most of the tables in this type of operation won''t be used except in these types of screens. Kevin http://kevin.is-a-geek.net
I haven''t seen ActiveRecord generating joins, but then I have only seen the generated SQL when I get an error. So far the types of relations I''m using all appear to be lazy-loaded. I''d really like someone to speak to this question in more detail. For instance, I am pretty certain my acts_as_tree and has_many are lazy loaded. I don''t see where the documentation speaks to this. If I were concerned about performance I''d want to control the SQL or at least confirm that it is sensible. Probably there is a good way to log the generated SQL? Kevin Davis wrote:>Hey there.. I''m in the process of demoing RoR as a viable framework >for use on a large web app we''re building. > >One of the views I''ll want to create is a join of about 5 tables, >presented in a long list, thousands of rows perhaps. I''m wondering the >best way to go about this? > >Ideally I wouldn''t be creating a view in the DB for every such screen >I want to create (kind of defies the MVC idea).. but is there an >elegant way to do this in Rails? Most of the tables in this type of >operation won''t be used except in these types of screens. > >Kevin >http://kevin.is-a-geek.net >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > > > >
tail -f log/development.log is better can documentation can possibly hope to be. Especially in combination with script/console. On Apr 5, 2005 10:33 PM, Jeremy Huffman <jeremy-S3UG9Ld25dVMf0S0rWojDQC/G2K4zDHf@public.gmane.org> wrote:> I haven''t seen ActiveRecord generating joins, but then I have only seen > the generated SQL when I get an error. So far the types of relations I''m > using all appear to be lazy-loaded. I''d really like someone to speak to > this question in more detail. For instance, I am pretty certain my > acts_as_tree and has_many are lazy loaded. I don''t see where the > documentation speaks to this. If I were concerned about performance I''d > want to control the SQL or at least confirm that it is sensible. > Probably there is a good way to log the generated SQL? > > Kevin Davis wrote: > > >Hey there.. I''m in the process of demoing RoR as a viable framework > >for use on a large web app we''re building. > > > >One of the views I''ll want to create is a join of about 5 tables, > >presented in a long list, thousands of rows perhaps. I''m wondering the > >best way to go about this? > > > >Ideally I wouldn''t be creating a view in the DB for every such screen > >I want to create (kind of defies the MVC idea).. but is there an > >elegant way to do this in Rails? Most of the tables in this type of > >operation won''t be used except in these types of screens. > > > >Kevin > >http://kevin.is-a-geek.net > >_______________________________________________ > >Rails mailing list > >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://www.hieraki.org - Open source book authoring http://blog.leetsoft.com - Technical weblog
Beautiful, thanks. Tobias Luetke wrote:>tail -f log/development.log is better can documentation can possibly >hope to be. >Especially in combination with script/console. > > >On Apr 5, 2005 10:33 PM, Jeremy Huffman <jeremy-S3UG9Ld25dVMf0S0rWojDQC/G2K4zDHf@public.gmane.org> wrote: > > >>I haven''t seen ActiveRecord generating joins, but then I have only seen >>the generated SQL when I get an error. So far the types of relations I''m >>using all appear to be lazy-loaded. I''d really like someone to speak to >>this question in more detail. For instance, I am pretty certain my >>acts_as_tree and has_many are lazy loaded. I don''t see where the >>documentation speaks to this. If I were concerned about performance I''d >>want to control the SQL or at least confirm that it is sensible. >>Probably there is a good way to log the generated SQL? >> >>Kevin Davis wrote: >> >> >> >>>Hey there.. I''m in the process of demoing RoR as a viable framework >>>for use on a large web app we''re building. >>> >>>One of the views I''ll want to create is a join of about 5 tables, >>>presented in a long list, thousands of rows perhaps. I''m wondering the >>>best way to go about this? >>> >>>Ideally I wouldn''t be creating a view in the DB for every such screen >>>I want to create (kind of defies the MVC idea).. but is there an >>>elegant way to do this in Rails? Most of the tables in this type of >>>operation won''t be used except in these types of screens. >>> >>>Kevin >>>http://kevin.is-a-geek.net >>>_______________________________________________ >>>Rails mailing list >>>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>>http://lists.rubyonrails.org/mailman/listinfo/rails >>> >>> >>> >>> >>> >>> >>_______________________________________________ >>Rails mailing list >>Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>http://lists.rubyonrails.org/mailman/listinfo/rails >> >> >> > > > >
I''m just new to rails and am undoubtedly missing something, but I don''t really see another (other than to create a view in the DB) way to approach fetching 1000s of rows 8 tables joined. Where should I go to learn more about this type of thing? Thanks! Kevin On Apr 5, 2005 10:33 PM, Jeremy Huffman <jeremy-S3UG9Ld25dVMf0S0rWojDQC/G2K4zDHf@public.gmane.org> wrote:> I haven''t seen ActiveRecord generating joins, but then I have only seen > the generated SQL when I get an error. So far the types of relations I''m > using all appear to be lazy-loaded. I''d really like someone to speak to > this question in more detail. For instance, I am pretty certain my > acts_as_tree and has_many are lazy loaded. I don''t see where the > documentation speaks to this. If I were concerned about performance I''d > want to control the SQL or at least confirm that it is sensible. > Probably there is a good way to log the generated SQL? > > Kevin Davis wrote: > > >Hey there.. I''m in the process of demoing RoR as a viable framework > >for use on a large web app we''re building. > > > >One of the views I''ll want to create is a join of about 5 tables, > >presented in a long list, thousands of rows perhaps. I''m wondering the > >best way to go about this? > > > >Ideally I wouldn''t be creating a view in the DB for every such screen > >I want to create (kind of defies the MVC idea).. but is there an > >elegant way to do this in Rails? Most of the tables in this type of > >operation won''t be used except in these types of screens. > > > >Kevin > >http://kevin.is-a-geek.net > >_______________________________________________ > >Rails mailing list > >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > >
Eager fetching will be part of the next release. But if you need to join over more then two table then you have different problems. Obviously you can find_by_sql to get this kind of data but you are probably better off just doing 8 queries and putting a fragment cache in place because this way you can take advantage of all the help AR gives you with relations. Honestly, just wanting a join like this is a good indication of a odd DB. Don''t forget that rails is geared for new legacy free development and because of this it does a better job at aiding this type of development then legacy aware systems like hibernate. It is made under the assumption that the Database is just a way to persist the data required by your models and business logic. Optimization comes from caching and not from 1990 style sql queries. That being said people added an array of tools to get legacy dbs working. Especially views seem to be very popular to get legacy db''s into AR mindset ( plural tables, lowercase columns, id for PK ). On Apr 6, 2005 9:37 AM, Kevin Davis <kgdavis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m just new to rails and am undoubtedly missing something, but I > don''t really see another (other than to create a view in the DB) way > to approach fetching 1000s of rows 8 tables joined. > > Where should I go to learn more about this type of thing? > > Thanks! > > Kevin > > On Apr 5, 2005 10:33 PM, Jeremy Huffman <jeremy-S3UG9Ld25dVMf0S0rWojDQC/G2K4zDHf@public.gmane.org> wrote: > > I haven''t seen ActiveRecord generating joins, but then I have only seen > > the generated SQL when I get an error. So far the types of relations I''m > > using all appear to be lazy-loaded. I''d really like someone to speak to > > this question in more detail. For instance, I am pretty certain my > > acts_as_tree and has_many are lazy loaded. I don''t see where the > > documentation speaks to this. If I were concerned about performance I''d > > want to control the SQL or at least confirm that it is sensible. > > Probably there is a good way to log the generated SQL? > > > > Kevin Davis wrote: > > > > >Hey there.. I''m in the process of demoing RoR as a viable framework > > >for use on a large web app we''re building. > > > > > >One of the views I''ll want to create is a join of about 5 tables, > > >presented in a long list, thousands of rows perhaps. I''m wondering the > > >best way to go about this? > > > > > >Ideally I wouldn''t be creating a view in the DB for every such screen > > >I want to create (kind of defies the MVC idea).. but is there an > > >elegant way to do this in Rails? Most of the tables in this type of > > >operation won''t be used except in these types of screens. > > > > > >Kevin > > >http://kevin.is-a-geek.net > > >_______________________________________________ > > >Rails mailing list > > >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > >http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://www.hieraki.org - Open source book authoring http://blog.leetsoft.com - Technical weblog