X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id C847911F6621 for ; Thu, 6 Apr 2006 11:48:12 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76087-03-3 for ; Thu, 6 Apr 2006 11:48:05 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from danbo.digsys.bg (danbo.digsys.bg [192.92.129.13]) by postgresql.org (Postfix) with ESMTP id E205911F665C for ; Thu, 6 Apr 2006 11:48:08 -0300 (ADT) Received: from [193.68.6.22] (kaloyan@luke.digsys.bg [193.68.6.22]) by danbo.digsys.bg (8.11.6/8.10.1) with ESMTP id k36Em8T04189 for ; Thu, 6 Apr 2006 17:48:08 +0300 (EEST) Message-ID: <44352A25.7010107@faith.digsys.bg> Date: Thu, 06 Apr 2006 17:48:05 +0300 From: Kaloyan Iliev User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.12) Gecko/20060117 X-Accept-Language: bg, en, en-us MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: CURSOR OR OFFSET/LIMIT Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=1.166 required=5 tests=[SUBJ_ALL_CAPS=1.166] X-Spam-Score: 1.166 X-Spam-Level: * X-Archive-Number: 200604/112 X-Sequence-Number: 18196 Hi, I am working on Web Based application using Perl and Apache. I have to show to the users some query results by pages. Some time the result can be over 1000 rows (but can be more). The question is how to make this. The one way is to use OFFSET and LIMIT. That's OK but every time the whole query must be parsed and executed. If I use cursors it's better but my problem is that cursors live only in the current transaction. So when the Web Server finish I've lost the transaction and the cursor. There is some software written from my coleagues that on every server request open a transaction and cursor. Move to the requested page and show the result(After that the script finishes, so is the transaction). So my question is. Should I rewrte this by using OFFSET/LIMIT or it is better every time to create the cursor and use it to get the rows. Is there a way to save the cursor between separe Browser request (and to give it time to live)? Or After all OFFSET and LIMIT? Thanks in advance. Kaloyan Iliev