Here is some additional info about ListProperty vs HABTM.

The same schema adding Membership tables instead of ListProperties:

db.define_table("Match",
      SQLField("ground", "string"),
      SQLField("result", "string"))

db.define_table("Team",
      SQLField("name", "string"))

db.define_table("Player",
      SQLField("name", "string"))

db.define_table("TeamMembership",
      SQLField("team_id", "integer"),
      SQLField("player_id", "integer"))

db.define_table("MatchMembership",
      SQLField("team_id", "integer"),
      SQLField("match_id", "integer"))

This is mostly equivalent to using a ListProperty, however you need 1
query extra of a Membership table to get the 'list' of ids, but also
to add/delete N items in a Membership you need N writes.

Having a normalized (3NF) schema (with either ListProperty or HABTM)
without joins requires N+1 queries to fetch things like all the player
names on a team (which is poor performance and you only get ~30
queries/req).  To get the performance back, you could selectively de-
normalize (store data redundantly), based on the queries that you
expect to perform.  So if your app needs all the player names for a
given team or all team names for a given player without a join in 1
query, you could also store the names in the TeamMembership:

db.define_table("TeamMembership",

      SQLField("team_id", "integer"),
      SQLField("team_name"))
      SQLField("player_id", "integer")
      SQLField("player_name"))

In this example, N+1 queries is now 1 query to get the player names
from a given team or team names for a given player.  The catch is that
if you need to change a name, you need to update the name for each
TeamMembership matching that id, which is N writes again...

The main benefit for ListProperty is that adding/removing N items from
the list is 1 write at your end, but bigtable still needs to build/
drop the N indexes and since its a synchronous call, it does not
return until it finishes, so using ListProperty in that one use case
should be cheaper than N writes.  But, added to GAE in August, batch
writes across entity groups ( 
http://googleappengine.blogspot.com/2008/08/couple-datastore-updates.html
) so now you could add/remove N items from a membership in parallel
with one batched write from your end (web2py does not support this).
How much is the N add/remove performance difference between
ListProperty and Membership batch writes?  That would be an
interesting benchmark to perform.  Another interesting point is that
ListProperties are limited to ~5000 items.

Robin

On Jan 2, 9:49 am, "sudhakar m" <[email protected]> wrote:
> Yep got the source 
> fromhttp://mdp.cti.depaul.edu/examples/static/1.55rc2/web2py_src.zip
>
> I will do some trials and post back.
>
> Sudhakar.M
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to