X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D21E65357E for ; Sat, 7 May 2005 15:00:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 57669-10 for ; Sat, 7 May 2005 18:00:12 +0000 (GMT) Received: from mail.gmx.net (pop.gmx.net [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id 06377538C9 for ; Sat, 7 May 2005 13:19:13 -0300 (ADT) Received: (qmail invoked by alias); 07 May 2005 16:12:30 -0000 Received: from p5495EE04.dip.t-dialin.net (EHLO pikkewyn.bienenet) [84.149.238.4] by mail.gmx.net (mp032) with SMTP; 07 May 2005 18:12:30 +0200 X-Authenticated: #1074748 Date: Sat, 7 May 2005 18:12:30 +0200 From: Vortex To: Bruno Wolff III Cc: pgsql-sql@postgresql.org Subject: Re: select within aggregate? Message-Id: <20050507181230.4044d498.vortex25@gmx.de> In-Reply-To: <20050506124923.GB14417@wolff.to> References: <20050506092535.060bca35.vortex25@gmx.de> <20050506124923.GB14417@wolff.to> Organization: private X-Mailer: Sylpheed version 1.0.3 (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.516 tagged_above=0 required=5 tests=FROM_ENDS_IN_NUMS X-Spam-Level: X-Archive-Number: 200505/76 X-Sequence-Number: 21389 On Fri, 6 May 2005 07:49:23 -0500 Bruno Wolff III wrote: > You could use max(ts) as long as you can have two requests occur at the > same time. This might be a reasonable assumption, but it might have been > better to include a sequence so that each record would be guaranteed to > have a unique key. Yes, of course. So far it was more a theoretical question. > Using DISTINCT ON to get the latest URIs is probably better. You can > join that query to the one doing the count. This will probably be more > efficient than executing a subquery for each remote host. The DISTINCT ON construction looks quite interesting. It seems to allow some sorting within an group (even althought it's no real aggregate) in general. I can't say if it's really more eficient than the solution suggested by R.Muralidharan. But i will do some tests! Thank you very much! Klaus