[PonyORM-list] Counting appearances of a row value

Matthew Bell matthewrobertbell at gmail.com
Wed Nov 5 08:12:30 UTC 2014


Of course, as soon as I send the email, I find something that works:

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

Is this the most efficient method?

On 5 November 2014 08:02, Matthew Bell <matthewrobertbell at gmail.com> wrote:

> 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
>



-- 
Regards,

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


More information about the ponyorm-list mailing list