Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 3FF889FBC54 for ; Thu, 22 Mar 2007 15:24:57 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 78948-01 for ; Thu, 22 Mar 2007 15:24:47 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.184]) by postgresql.org (Postfix) with ESMTP id 3BE2E9FBBC0 for ; Thu, 22 Mar 2007 15:24:47 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id x4so1667986nfb for ; Thu, 22 Mar 2007 11:24:46 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=K0ZJEo1uQi90ZFjFI052A7BdSGYeGJ5p5nopggd7TgTCa0FnJ8nkrYK5YAmB1O+JNAPOUFvbn/vUc0fWZGYtIKi8D4gi54NfB3ccGRGeEFlOA4V8qvea2QFNTctlVUnd2TeMvJQetPyK6kfVjopvdpHqWpeyVDQR0WdPE55Ots0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=gYUHQSMV71Tb6Q/usycxbsoI2fW+fopywWyfLTrX0r0xTk5tTqOmsnFs4t1UCL7q7KZv3lTGvNKT6JOG1MjKCshv7XaedayJ/pF1dV0lImw+vbs+Jwx+6ongj/PLymc7/p7S2fKJfqXJO+o/Cn+FR6xMsZWJfKghaYY67bop9no= Received: by 10.78.142.14 with SMTP id p14mr1125821hud.1174587879767; Thu, 22 Mar 2007 11:24:39 -0700 (PDT) Received: by 10.78.35.18 with HTTP; Thu, 22 Mar 2007 11:24:39 -0700 (PDT) Message-ID: Date: Thu, 22 Mar 2007 14:24:39 -0400 From: "Merlin Moncure" To: pgsql-performance@postgresql.org Subject: Re: Performance of count(*) In-Reply-To: <20070322173930.GI11402@mathom.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200703221208.19358.albert@sedifa.com> <20070322141807.GE11402@mathom.us> <46029DE3.9030505@modgraph-usa.com> <4602A15B.7000908@wildenhain.de> <4602BB19.9050306@modgraph-usa.com> <4602BC84.8030101@wildenhain.de> <20070322173930.GI11402@mathom.us> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/350 X-Sequence-Number: 23755 On 3/22/07, Michael Stone wrote: > On Thu, Mar 22, 2007 at 06:27:32PM +0100, Tino Wildenhain wrote: > >Craig A. James schrieb: > >>You guys can correct me if I'm wrong, but the key feature that's missing > >>from Postgres's flexible indexing is the ability to maintain state > >>across queries. Something like this: > >> > >> select a, b, my_index_state() from foo where ... > >> offset 100 limit 10 using my_index(prev_my_index_state); > >> > > > >Yes, you are wrong :-) The technique is called "CURSOR" > >if you maintain persistent connection per session > >(e.g. stand allone application or clever pooling webapplication) > > Did you read the email before correcting it? From the part you trimmed > out: > > >The problem is that relational databases were invented before the web > >and its stateless applications. In the "good old days", you could > >connect to a database and work for hours, and in that environment > >cursors and such work well -- the RDBMS maintains the internal state of > >the indexing system. But in a web environment, state information is > >very difficult to maintain. There are all sorts of systems that try > >(Enterprise Java Beans, for example), but they're very complex. > > It sounds like they wrote their own middleware to handle the problem, > which is basically what you suggested (a "clever pooling web > application") after saying "wrong". Tino was saying that rather that build a complete indexing storage management solution that lives outside the database, it is better to do intelligent session management so that you get the simplicity if a two tier client server system but the scalability of a web app. Web apps are not necessarily stateless, you just have to be a little clever about how database connections are opened and closed. Then you get all the database stuff that comes along with a persistent connection (advisory locks, cursors, prepared statements, etc) without building all kinds of data management into the middleware. merlin