From: | elein <elein(at)varlena(dot)com> |
---|---|
To: | Greg Stark <gsstark(at)mit(dot)edu> |
Cc: | elein <elein(at)varlena(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, Rod Taylor <pg(at)rbt(dot)ca>, Jeff Boes <jboes(at)nexcerpt(dot)com>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: SQL challenge--top 10 for each key value? |
Date: | 2004-04-11 18:20:42 |
Message-ID: | 20040411112042.B9217@cookie.varlena.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
No, it will not work twice in the same query as is.
If you want to code two counter buckets and pass in
some way to distinguish between the two yada yada yada
it is possible. It is also possible to code this to
do multi-level counting/breaks/calculations, etc.
But the SD dictionary is by connection. So any values
stored in it need to be initialized at the appropriate
time *outside* of the first use.
elein
On Sun, Apr 11, 2004 at 12:38:20AM -0400, Greg Stark wrote:
>
> elein <elein(at)varlena(dot)com> writes:
>
> > create or replace function pycounter(integer)
> > returns integer as
> > '
> > if args[0] == 0:
> > SD["nextno"] = 1
> > return SD["nextno"]
> > try:
> > SD["nextno"] += 1
> > except:
> > SD["nextno"] = 1
> > return SD["nextno"]
> > ' language 'plpythonu';
> >
> > And clearly it can be done faster as a little
> > C function.
>
> Does this approach have a hope of working if it's used twice in the same
> query?
>
>
> --
> greg
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
> joining column's datatypes do not match
From | Date | Subject | |
---|---|---|---|
Next Message | Dennis | 2004-04-11 18:46:01 | Re: cursors and for loops? |
Previous Message | Tom Lane | 2004-04-11 16:00:55 | Re: cursors and for loops? |