From: | Gregory Stark <stark(at)enterprisedb(dot)com> |
---|---|
To: | Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> |
Cc: | tmp <skrald(at)amossen(dot)dk>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Optimizing DISTINCT with LIMIT |
Date: | 2008-12-04 14:32:07 |
Message-ID: | 871vwo1060.fsf@oxford.xeocode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> writes:
> Gregory Stark wrote:
> Does that know to stop scanning as soon as it has seen 5 distinct values?
Uhm, hm. Apparently not :(
postgres=# create or replace function v(integer) returns integer as $$begin raise notice 'called %', $1; return $1; end$$ language plpgsql volatile;
CREATE FUNCTION
postgres=# select distinct v(i) from generate_series(1,10) as a(i) limit 3;
NOTICE: 00000: called 1
LOCATION: exec_stmt_raise, pl_exec.c:2542
NOTICE: 00000: called 2
LOCATION: exec_stmt_raise, pl_exec.c:2542
NOTICE: 00000: called 3
LOCATION: exec_stmt_raise, pl_exec.c:2542
NOTICE: 00000: called 4
LOCATION: exec_stmt_raise, pl_exec.c:2542
NOTICE: 00000: called 5
LOCATION: exec_stmt_raise, pl_exec.c:2542
NOTICE: 00000: called 6
LOCATION: exec_stmt_raise, pl_exec.c:2542
NOTICE: 00000: called 7
LOCATION: exec_stmt_raise, pl_exec.c:2542
NOTICE: 00000: called 8
LOCATION: exec_stmt_raise, pl_exec.c:2542
NOTICE: 00000: called 9
LOCATION: exec_stmt_raise, pl_exec.c:2542
NOTICE: 00000: called 10
LOCATION: exec_stmt_raise, pl_exec.c:2542
v
---
5
4
6
(3 rows)
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Ask me about EnterpriseDB's PostGIS support!
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2008-12-04 14:35:26 | Re: Optimizing DISTINCT with LIMIT |
Previous Message | Heikki Linnakangas | 2008-12-04 14:20:17 | Re: Optimizing DISTINCT with LIMIT |