[PonyORM-list] Counting appearances of a row value

Matthew Bell matthewrobertbell at gmail.com
Wed Nov 5 08:02:28 UTC 2014


Hi,

I have naively tried to execute this query:

models.select((r.date, models.count(r.date)) for r in models.Result if
r.date >= datetime.date.today() -
datetime.timedelta(days=10)).without_distinct()

With the aim of counting how many times each date appears. I was doing this
with collections.Counter, but this doesn't scale to millions of results
(far too much CPU and memory used). What query can I use to make the
database do the work?

Thanks
-- 
Regards,

Matthew Bell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </ponyorm-list/attachments/20141105/4bff0b6a/attachment.html>


More information about the ponyorm-list mailing list