I'm trying to implement a summary view on to a large(ish) data set using AppEngine.

My model looks something like:

```
def TxRecord(db.Model):
    expense_type = db.StringProperty()
    amount = db.IntegerProperty()

def ExpenseType(db.Model):
    name = db.StringProperty()
    total = db.IntegerProperty()

```

My datastore contains 100K instances of `TxRecord` and I'd like to summarise these by `expense_type`.

In sql it would be something like:

```
select expense_type as name, sum(amount) as total 
    from TxRecord
    group by expense_type

```

What I'm currently doing is using the [Python MapReduce framework](http://code.google.com/p/appengine-mapreduce/) to iterate over all of the `TxRecords` using the following mapper:

```
def generate_expense_type(rec):
    expense_type = type.get_or_insert(name, name = rec.expense_type)
    expense_type.total += rec.amount

    yield op.db.Put(expense_type)

```

This seems to work, but I feel I have to run it using a `shard_count` of 1 in order to ensure that the total isn't over written with concurrent writes.

Is there a strategy that I can use to over come this issue using AppEngine or is that it?