Re: cursor MOVE vs OFFSET in SELECT

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
Cc: silly8888 <silly8888(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: cursor MOVE vs OFFSET in SELECT
Date: 2009-10-26 12:07:20
Message-ID: 162867790910260507n6e2d8f55q8137adf4b513e600@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2009/10/26 Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>:
>
>
> On Mon, Oct 26, 2009 at 10:30 AM, silly8888 <silly8888(at)gmail(dot)com> wrote:
>>
>> Suppose that you have a query, say $sql_query, which is very
>> complicated and produces many rows. Which of the following is going to
>> be faser:
>>
>>    $sql_query OFFSET 3000 LIMIT 12;
>>
>> or
>>
>>    BEGIN;
>>    DECLARE cur1 CURSOR FOR $sql_query;
>>    MOVE 3000 IN cur1;
>>    FETCH 12 FROM cur1;
>>    COMMIT;
>>
>> Naturally, the former cannot be slower than the latter. So my question
>> essentially is whether the MOVE operation on a cursor is
>> (significantly) slower that a OFFSET on the SELECT.
>
>
> OFFSET/LIMIT. Afaik cursor always fetches everything.

OFFSET/LIMIT process same rows as cursor. There could be only one
difference. Cursors uses strategy "fast first row", SELECT uses
"minimum complete query time".

Regards
Pavel Stehule

>
>
> --
> GJ
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Radcon Entec 2009-10-26 12:48:42 Logging statements with errors in PostgreSQL 8.1
Previous Message silly8888 2009-10-26 11:14:11 Re: cursor MOVE vs OFFSET in SELECT