It seems that deciding which approach is "better" would be on a
case-by-case basis, depending on factors such as:
-how many users are typically hitting the system
-how much of a load is the database usually under
-how often are items in the database updated
and most importantly - how vital is it that search results are
returned to users up-to-date -- of course, that''s usually very
important, as users don''t like being confused or mistaken, which is
what happens when they get out-of-date results and end up trying to
order a product that had actually sold out since their session first
started.
caching a result set into memory seems more computationally efficient
initially, but in the end it seems like less of a headache compared to
just putting the proper development time in, indexing your database
and tweaking whatever else is needed in order to deliver results in
real-time.
-marcus
On 6/28/05, Ben Robison
<benrobb-tG9VLQz9vMNvVe5bR5WX4wC/G2K4zDHf@public.gmane.org>
wrote:> I work in a small team of two, consisting of myself and Duane Johnson (a
> fellow ruby stud on the rails list). We are just now finishing my first
> rails application - http://www.filmfury.com - and looking back at the
> last 2 months. In the process of discussing this project and looking
> forward into the next one, we started discussing some general layout and
> architecture of an application, and for the purposes of this email,
> specifically the search functionality. We have two different approaches
> and are trying to decide which is better, which would be simpler to keep
> track of and most efficient with resources.
>
> (1) In this last project, we used the session to store everything that
> we would need to exactly duplicate a query every time someone switched
> pages. This means, that pagination, search parameters, sort parameters,
> etc, were all stored in the session, so if someone wanted to go to page
> 2, we would re-execute their original query, sort it, and display the
> proper page, all controlled by session variables.
>
> (2) Having just come off a Java project, and being a fairly new
> programmer, I had just done a different project where we had executed
> their original query, and then stored the results as a session variable,
> performing different sorts, etc, as needed, but performing all those
> actions on one result set stored in the session.
>
> Both have advantages and disadvantages, and we were wondering what
> everybody''s thoughts on this are? Is there a best practices
method for
> doing things like this? What does everybody think?
>
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.323 / Virus Database: 267.8.5/32 - Release Date: 6/27/2005
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>