I use raw SQL for pretty much anything that requires joining more than one table. For example, on http://urbandrinks.com, there is no way I could use the standard ActiveRecord way of doing things to select all the happy hours on a given day or during a particular time range. If I did, I would have code chunks that looked something like place.day.time_range.specials.each.... and would require a million small queries.
For something like what you're talking about where a user defines a database, you would surely need to use some custom SQL, which seems to perform quite well in Rails. Good luck, Bryan (p.s., the ruby and sql on urbandrinks.com is actually very fast.. it's the google map and serving the graphs that's slow.. ugh.) On 1/3/07, Moxley Stratton <[EMAIL PROTECTED]> wrote: > Topher Cyll wrote: > > Hey Moxley, > > > > At my old job we did hit performance problems using ActiveRecord (the > > Rails ORM) on some complicated DB topologies. The good news, however, > > was that it was simple to drop back down to using raw SQL from within > > Rails and avoid ActiveRecord in the few spots that it was too slow. > > > That's good news. > > Now that you've mentioned it, ActiveRecord did seem like the part of the > Rails equation that seemed like the weak spot for certain parts of the > project. I suppose I can ditch ActiveRecord for the parts of the app > that need a more customized ORM (if ORM is even the correct term for > what it will be. O?M). > > That said, it sounds like you're doing something pretty complicated. > > Can you expand a little on what you mean by per-user-dynamic-model? > > > Without going into the proprietary details of the project, I'll use a > metaphore. There's a particular part of the application that is a like a > user-defined database, where the user can define the schema. For this > discussion, I'll call this user role a Maintainer. There may be > thousands of Maintainers, each with their own database. > > Because that a) the databases are user-defined, and b) there will be > thousands of them, I'll make the assumption that Maintainers cannot have > their own physical database (or physical set of tables). Instead, a more > exotic scheme would be needed. What will that scheme look like? I'm not > sure. The first idea that popped in my head involved storing XML in an > RDBMS that knows how to query XML (e.g., MySQL can). > > In that situation, I might be tempted to write my own hard-coded model > > that supported your operations directly without going through AR. Was > > that what you were considering doing in PHP anyways? > > > Yes. > > With a solution like that, at least you could have the advantage of > > Rails and Ruby, just minus ActiveRecord. > > > That's a good point. It really is the ActiveRecord part the equation > that has me worried for this project. Rails minus ActiveRecord is a good > solution for those area of the app that find ActiveRecord too constraining. > > However, now we're on the topic of Rails' presentation tier, I really > miss the ability of PHP (and mod_ruby + .rhtml) to imbed the framework > inside the web site instead of the other way around. I want to create a > system that doesn't involve cramping the web designer too much. Any > thoughts on that? > > > Anyways, I'll be curious to see what you end up settling on and how it > > works out for you. > > > I'll let you know. > > -Moxley > > > Toph > > > > > > On 1/3/07, Moxley Stratton <[EMAIL PROTECTED]> wrote: > > > >> What I mean is that there are several vectors contributing to the > >> complexity: 1) a sophisticated business data model, 2) A corresponding > >> data model in the rdbms, 3) The business model with a dynamic nature to > >> it. It is defined at runtime on a per-user basis. 4) Significant query > >> requirements involving dynamic model described above. 5) High > >> performance requirements. > >> > >> It seems to me that Rails can handle 1, 2 and maybe 4 without any > >> issues. I'm less sure about 3 and 5, and I'm even less sure about the > >> combination of 1 through 5. > >> > >> Moxley > >> > >> p.s., I mis-typed the url in my first post. It is > >> http://www.moxleystratton.com/ > >> > >> Bryan Donovan wrote: > >> > >>> Hi Moxley, > >>> > >>> What do you mean by complex data access, and why do you think Rails > >>> would be unsuitable for this? > >>> > >>> Regards, > >>> Bryan > >>> http://urbandrinks.com > >>> > >>> > >>> On 1/3/07, Moxley Stratton <[EMAIL PROTECTED]> wrote: > >>> > >>> > >>>> Hello all, > >>>> > >>>> I'm new to the group. You may remember me at your Free Geek meetings. > >>>> I'm the PHP user group guy who sometimes holds your projector hostage. > >>>> Sorry about that. > >>>> > >>>> Anyway, I've been hired to work on a new project. It is a new > >>>> collaborative/social web site in the vein of Wikipedia and MySpace. I > >>>> really want to do the site in Ruby because I like it and I'm getting > >>>> tired of PHP and it's wimpy language design. > >>>> > >>>> PHP is my fall-back choice if I can't quickly strategize a Ruby > >>>> solution. It is a much larger phenomenon than Ruby, and it has a proven > >>>> track record on large sites, like Yahoo for instance. As far as I know, > >>>> Ruby doesn't have such a track record for web development. > >>>> > >>>> My first-choice Ruby strategy is to use mod_ruby and use a development > >>>> style that looks a lot like my PHP style, wherein I start from scratch > >>>> and develop a framework around the requirements instead of trying to > >>>> tweak an existing framework (e.g., Rails) to fit the requirements. Rails > >>>> seems too constraining for the complex data access and performance > >>>> requirements of this project. I'd like to hear opinions about this. > >>>> > >>>> Regardless of what Ruby strategy I take, it really would be great if > >>>> there was a solid software designer with real-world Ruby web experience > >>>> who could partner with me with design decisions and maybe code too. It > >>>> would be part-time help and it would start right away. The site is > >>>> expected to launch in about six months. > >>>> > >>>> Best regards, > >>>> > >>>> Moxley Stratton > >>>> http://www.moxleystratton.com/ > >>>> > >>>> _______________________________________________ > >>>> PDXRuby mailing list > >>>> [email protected] > >>>> IRC: #pdx.rb on irc.freenode.net > >>>> http://lists.pdxruby.org/mailman/listinfo/pdxruby > >>>> > >>>> > >>>> > >>> _______________________________________________ > >>> PDXRuby mailing list > >>> [email protected] > >>> IRC: #pdx.rb on irc.freenode.net > >>> http://lists.pdxruby.org/mailman/listinfo/pdxruby > >>> > >>> > >> _______________________________________________ > >> PDXRuby mailing list > >> [email protected] > >> IRC: #pdx.rb on irc.freenode.net > >> http://lists.pdxruby.org/mailman/listinfo/pdxruby > >> > >> > > _______________________________________________ > > PDXRuby mailing list > > [email protected] > > IRC: #pdx.rb on irc.freenode.net > > http://lists.pdxruby.org/mailman/listinfo/pdxruby > > > > _______________________________________________ > PDXRuby mailing list > [email protected] > IRC: #pdx.rb on irc.freenode.net > http://lists.pdxruby.org/mailman/listinfo/pdxruby > _______________________________________________ PDXRuby mailing list [email protected] IRC: #pdx.rb on irc.freenode.net http://lists.pdxruby.org/mailman/listinfo/pdxruby
