Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 5EEDF2E004E for ; Wed, 21 May 2008 13:20:40 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 02451-09 for ; Wed, 21 May 2008 13:20:36 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from 30.mail-out.ovh.net (30.mail-out.ovh.net [213.186.62.213]) by developer.postgresql.org (Postfix) with SMTP id 20CCE2E0046 for ; Wed, 21 May 2008 13:20:36 -0300 (ADT) Received: (qmail 31833 invoked by uid 503); 21 May 2008 16:20:56 -0000 Received: from unknown (HELO mail243.ha.ovh.net) (213.186.33.59) by 30.mail-out.ovh.net with SMTP; 21 May 2008 16:20:56 -0000 Received: from b0.ovh.net (HELO queue-out) (213.186.33.50) by b0.ovh.net with SMTP; 21 May 2008 16:20:31 -0000 Received: from par69-8-88-161-102-87.fbx.proxad.net (HELO apollo13.peufeu.com) (88.161.102.87) by ns0.ovh.net with SMTP; 21 May 2008 16:20:29 -0000 Date: Wed, 21 May 2008 18:27:14 +0200 To: "H. Hall" , pgsql-performance@postgresql.org Subject: Re: "Big O" notation for postgres? From: PFC Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 References: <48342D6D.1020506@reedyriver.com> Content-Transfer-Encoding: Quoted-Printable Message-ID: In-Reply-To: <48342D6D.1020506@reedyriver.com> User-Agent: Opera Mail/9.24 (Linux) X-Ovh-Tracer-Id: 5462021923637429786 X-Ovh-Remote: 88.161.102.87 (par69-8-88-161-102-87.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|H 0.5/N X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.645 tagged_above=0 required=5 tests=AWL=0.645 X-Spam-Level: X-Archive-Number: 200805/298 X-Sequence-Number: 30266 On Wed, 21 May 2008 16:10:53 +0200, H. Hall = wrote: > Does anyone know if there is a source that provides "Big O" notation f= or = > postgres's aggregate functions and operations? For example is count(*= ) = > =3D O(1) or O(n)? > > Do the developers for postgres use Big O when selecting algorithms? If= = > so, is the info easily available? You can't do any better than O( n rows examined by the aggregate ) exce= pt = for max() and min() on an indexed expression, which in this case aren't = = really aggrgates anymore since they are internally rewritten as an index= = lookup to get the value you want... but stuff like sum() or avg() or = count() will always have to see all the rows selected (and some more) = unless you use clever hacks like materialized views etc, in which case t= he = thing in the O() will change, or at least the O() constant will change..= .