On Wed, Nov 26, 2008 at 5:55 PM, Joachim A. <[EMAIL PROTECTED]>wrote:

>
> Hi,
> after profiling my lift application (which uses the mapper classes) I
> found out that most of the time is spend doing SQL queries. Displaying
> medium-sized tabular data executes hundreds of (mostly small) queries.
> This takes a lot of time.
>
> I understand that the mapper implementation is not optimized.


This is not correct.  The Mapper stuff is fairly well optimized.  It, in
general, executes 6 times faster than ActiveRecord, running the same queries
(thus destroying any of Rail's claims about the time being spent in the
database.)


>
>
> - Is there any way for me to optimize this?  E.g. enabling caching,
> enabling something like prefetching, ... ?


I generally write hand-code that pre-fetches.  This generally results in
significant performance improvements (and 2 or 3 queries per page-load.)

for example:
val users: List[User] = User.findAll(By(User.zip, "02135"))
val schools: Map[Long, School] = Map(School.findAll(In.fk(User.school,
By(User.zip, "02135")).
                                                                map(s => (
s.id.is, s)) :_*)

Then you can look up schools without going to the RDBMS.  Also, the RDBMS
will likely have the results of the first query still in cache, so the
second query is very inexpensive.


>
>
> - Did anyone do db query profiling / optimization with lift before?
> What have the results been?


Huge performance improvements.


>
>
> - What is a good way to cache queries generated by MetaMapper.find()
> and findAll() ?


I leave this to the RDBMS.  If you're doing a read-heavy app (like a CMS
system), I'd manually build a cache in memory... as long as I was sure there
were no external apps that could update the RDBMS out from under me.


>
>
>
> Thank you for your patience - I'm still a lift learner :)
> Joachim
>
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to