pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Stark <gsstark@mit.edu>
To: elein <elein@varlena.com>
Cc: Josh Berkus <josh@agliodbs.com>
Cc: Rod Taylor <pg@rbt.ca>
Cc: Greg Stark <gsstark@mit.edu>
Cc: Jeff Boes <jboes@nexcerpt.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: SQL challenge--top 10 for each key value?
Date: 11 Apr 2004 00:38:20 -0400
Message-ID: <871xmvf7sz.fsf@stark.xeocode.com> (raw)
In-Reply-To: <20040410164651.K409@cookie.varlena.com>
References: <33af4fa4e4ec230574cefcff737ea40a@news.teranews.com>
	<87r7uyf3ki.fsf@stark.xeocode.com>
	<1081481466.56361.808.camel@jester>
	<200404090906.39541.josh@agliodbs.com>
	<20040410164651.K409@cookie.varlena.com>


elein <elein@varlena.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




view thread (16+ messages)  latest in thread

Message-ID: <871xmvf7sz.fsf@stark.xeocode.com>
Permalink:  ../871xmvf7sz.fsf@stark.xeocode.com/
Also on:    postgresql.org/message-id/871xmvf7sz.fsf@stark.xeocode.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gsstark@mit.edu, elein@varlena.com, josh@agliodbs.com, pg@rbt.ca, jboes@nexcerpt.com
  Subject: Re: SQL challenge--top 10 for each key value?
  In-Reply-To: <871xmvf7sz.fsf@stark.xeocode.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox