Re: GROUP BY without using aggregate function

2016-03-03 Thread marcin . j . nowak
On Thursday, March 3, 2016 at 2:28:58 PM UTC+1, Michal Petrucha wrote: > > > Merely based on your vague description, it seems to me that this is > one of the cases where you might be better off writing your SQL query > manually. > > Narrowing results by `filter()` is very handy, in contrast to

Re: GROUP BY without using aggregate function

2016-03-03 Thread Michal Petrucha
On Wed, Mar 02, 2016 at 09:21:03AM -0800, marcin.j.no...@gmail.com wrote: > > > On Wednesday, March 2, 2016 at 6:11:32 PM UTC+1, Dan Tagg wrote: > > > > if your aren't counting or averaging then why are you grouping? > > > > > > > To fast find distinct values within big dataset - some queries on

Re: GROUP BY without using aggregate function

2016-03-02 Thread marcin . j . nowak
On Wednesday, March 2, 2016 at 6:11:32 PM UTC+1, Dan Tagg wrote: > > if your aren't counting or averaging then why are you grouping? > > > To fast find distinct values within big dataset - some queries on some engines may be faster when using grouping. It was known technique years ago and I'm s

Re: GROUP BY without using aggregate function

2016-03-02 Thread Dan Tagg
if your aren't counting or averaging then why are you grouping? D On 2 March 2016 at 17:06, wrote: > Hello, > > I would like to query database with Django ORM and add GROUP BY clause > without including unnecessary counting, avg, etc. > I can force/hack queryset by settting qs.query.group_by=['

GROUP BY without using aggregate function

2016-03-02 Thread marcin . j . nowak
Hello, I would like to query database with Django ORM and add GROUP BY clause without including unnecessary counting, avg, etc. I can force/hack queryset by settting qs.query.group_by=['my_column'], but this is unclean and risky. Is possible something like: MyModel.objects.filter(...).group_by