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 847173A3F4B for ; Tue, 9 Nov 2004 09:16:40 +0000 (GMT) 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 30279-09 for ; Tue, 9 Nov 2004 09:16:29 +0000 (GMT) Received: from b.relay.invitel.net (b.relay.invitel.net [62.77.203.4]) by svr1.postgresql.org (Postfix) with ESMTP id 629FD3A3F48 for ; Tue, 9 Nov 2004 09:16:30 +0000 (GMT) Received: from vadangyal.vnet.hu (mail.vnet.hu [213.163.59.4]) by b.relay.invitel.net (Invitel Core SMTP Transmitter) with ESMTP id E9B11387A4 for ; Tue, 9 Nov 2004 10:16:28 +0100 (CET) Received: from [192.168.0.144] (82-131-187-234.vnet.hu [82.131.187.234]) by mail.vnet.hu (iPlanet Messaging Server 5.1 Patch 1 (built Jun 6 2002)) with ESMTPA id <0I6W00EHUN38HF@mail.vnet.hu> for pgsql-sql@postgresql.org; Tue, 09 Nov 2004 10:16:28 +0100 (CET) Date: Tue, 09 Nov 2004 10:16:22 +0100 From: Andras Kutrovics Subject: Re: Simple SQL Question In-reply-to: <1099678157.39887.15.camel@taz.oficina> To: pgsql-sql@postgresql.org Message-id: <41908AE6.80202@freemail.hu> MIME-version: 1.0 Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 0.9 (Windows/20041103) X-Enigmail-Version: 0.86.1.0 X-Enigmail-Supports: pgp-inline, pgp-mime References: <418BB051.6070808@freemail.hu> <1099678157.39887.15.camel@taz.oficina> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200411/77 X-Sequence-Number: 19396 Franco Bruno Borghesi wrote: Hi! Sorry for being late with the answer, I was busy at one of our customer;) > wouldn't it be easier using offset & limit?: you always select from the > table with an itemkey,location order by clause. You save the current > offset between requests, and for every request you re-execute the query > with a different offset. Sure, but sometimes I have to query by name, and dont want to create another query component. > If you still want to go with what you already have, you should keep the > lastItemKey and lastLocaltion values between requests, and your where > clause should be something like: > WHERE (itemKey=:lastItemKey AND location>:lastLocation) OR > (itemKey>:lastItemKey) It works perfectly, but I have to consider the performance issue, because if i use 'or' statement, postgres doesn't use index scan, and I also have tables with 3 or more keys and 500.000 records , where the performance of this method is poor. Maybe I will end up using limit and offset in case of incremental fetching,but if the table is modified between requests, it can behave weird. Is there a perfect solution to this? Sorry for the english Thank you again, Andras Kutrovics