Re: [GENERAL] Function with limit and offset - PostgreSQL 9.3 - Mailing list pgsql-general

From David G. Johnston
Subject Re: [GENERAL] Function with limit and offset - PostgreSQL 9.3
Date
Msg-id CAKFQuwYjoMiAfzG9j2LUanHxPiLOdmUP6WnwtMHnTb-r6QyqKQ@mail.gmail.com
Whole thread Raw
In response to Re: [GENERAL] Function with limit and offset - PostgreSQL 9.3  (marcinha rocha <marciaestefanidarocha@hotmail.com>)
List pgsql-general
On Thursday, June 8, 2017, marcinha rocha <marciaestefanidarocha@hotmail.com> wrote:

On Thursday, June 8, 2017, marcinha rocha <marciaestefanidarocha@hotmail.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. 

pgsql-general by date:

Previous
From: marcinha rocha
Date:
Subject: Re: [GENERAL] Function with limit and offset - PostgreSQL 9.3
Next
From: John R Pierce
Date:
Subject: Re: [GENERAL] Function with limit and offset - PostgreSQL 9.3