ntile() throws ERROR when hashagg is false

From: Rajkumar Raghuwanshi <rajkumar(dot)raghuwanshi(at)enterprisedb(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: ntile() throws ERROR when hashagg is false
Date: 2018-06-14 06:06:16
Message-ID: CAKcux6nQaoZ9re4GxA15MA+uii4g3H9DHJeRm30UZw5Ln93MAA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

ntile() throws ERROR when hashagg is false, test case given below.

postgres=# create table foo (a int, b int, c text);
CREATE TABLE
postgres=# insert into foo select i%20, i%30, to_char(i%12, 'FM0000') from
generate_series(0, 36) i;
INSERT 0 37
postgres=# explain select ntile(a) OVER () from foo GROUP BY a;
QUERY PLAN
-------------------------------------------------------------------
WindowAgg (cost=25.00..29.50 rows=200 width=8)
-> HashAggregate (cost=25.00..27.00 rows=200 width=4)
Group Key: a
-> Seq Scan on foo (cost=0.00..22.00 rows=1200 width=4)
(4 rows)

postgres=# select ntile(a) OVER () from foo GROUP BY a;
ntile
-------
1
1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
11
(20 rows)

postgres=# set enable_hashagg to false;
SET
postgres=# explain select ntile(a) OVER () from foo GROUP BY a;
QUERY PLAN
-------------------------------------------------------------------------
WindowAgg (cost=83.37..91.87 rows=200 width=8)
-> Group (cost=83.37..89.37 rows=200 width=4)
Group Key: a
-> Sort (cost=83.37..86.37 rows=1200 width=4)
Sort Key: a
-> Seq Scan on foo (cost=0.00..22.00 rows=1200 width=4)
(6 rows)
postgres=# select ntile(a) OVER () from foo GROUP BY a;
ERROR: argument of ntile must be greater than zero

Thanks & Regards,
Rajkumar Raghuwanshi
QMG, EnterpriseDB Corporation

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2018-06-14 06:52:51 Re: WAL prefetch
Previous Message Thomas Munro 2018-06-14 05:30:55 Re: Postgres, fsync, and OSs (specifically linux)