On Sat, Sep 27, 2008 at 5:26 AM, Ilia Lobsanov <[EMAIL PROTECTED]> wrote:
>
> I know aggregates have been discussed a lot already and that the way
> to do it is at write time.
>
> However my application is a full text search engine where each keyword
> produces a different result set. I need to report the sum and count
> for the entities in a given result set.
>
> Example: search a datastore of Contract entities where a Contract
> model has an attribute "contract_value". I need to get
> sum(contract_value) for all the entities for the search.
>
> How would you do this? Writing a count and sum for each possible
> search keyword is mind boggling.

Drink some coffee, and go boggle your mind!

As it stands*** AppEngine is really suited for applications where
reads way out numbers writes. So spending a bit of extra time at write
time will save you exponentially at read time.

So you either do it at write time, or loop though all results and
calculate the sum at runtime (and remeber to cache it for next time!).
Anything that loops though all your data (to calcate the sum) is
always going to be expensive - so do it once at write time.

A RDMS makes it almost trival to loop though all your data at runtime
- and a reason they dont scale well. Yes they can add an index (which
might help) - which is what you doing manually* on the datastore. (so
you only do it when it really needed :)


* (ie yourself - rather than transparently on the system)



... this has been a hard thing for me to accept personally, but it
makes sence when you really think about it.



*** once/if AppEngine supports background processing (ala MapReduce)
then this incremental index building will get easier, e.g. you create
a task that creates you a sum/count index , atm it has to be handled
at application level. But with this index built for you it will be
transaprent at app level.


> >
>



-- 
Barry

- www.nearby.org.uk - www.geograph.org.uk -

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

Reply via email to