Re: Function with limit and offset - PostgreSQL 9.3

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: marcinha rocha <marciaestefanidarocha(at)hotmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Function with limit and offset - PostgreSQL 9.3
Date: 2017-06-09 02:47:49
Message-ID: CAKFQuwYjoMiAfzG9j2LUanHxPiLOdmUP6WnwtMHnTb-r6QyqKQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thursday, June 8, 2017, marcinha rocha <marciaestefanidarocha(at)hotmail(dot)com>
wrote:

> On Thursday, June 8, 2017, marcinha rocha <marciaestefanidarocha@
> hotmail.com
> <javascript:_e(%7B%7D,'cvml','marciaestefanidarocha(at)hotmail(dot)com');>>
> wrote:
>
>> On my original select, the row will have migrated = false. Maybe All I
>> need to put is a limit 2000 and the query will do the rest?
>>
>>
> You shoud try to avoid the for loop,
>
> Why?
>

Mainly expected performance concerns. The engine is designed to handle
results sets as opposed to single row iterating. Whether it's true in your
case I don't know but I would assume that operating on sets would be faster.

>
> Ok, cool!
>
> Now, how do tell the function to return the number of touched rows? On
> this case, it should always be 2000.
>
>
Unless there are fewer rows to process. You could always just do i = i + 1
in the loop.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2017-06-09 04:56:05 Re: Function with limit and offset - PostgreSQL 9.3
Previous Message marcinha rocha 2017-06-09 02:13:37 Re: Function with limit and offset - PostgreSQL 9.3