Обсуждение: Bulk row fetching

Поиск
Список
Период
Сортировка

Bulk row fetching

От
"Carmen Wai"
Дата:
Hello:

Do anyone know whether libpq of postgresql can support bulk row fetching,
which allow multiple records to be retrieved at once during a single fetch,
rather than retrieving one record at a time?

Carmen

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx


Re: Bulk row fetching

От
Martijn van Oosterhout
Дата:
On Thu, Aug 15, 2002 at 02:41:57PM +0000, Carmen Wai wrote:
> Hello:
>
> Do anyone know whether libpq of postgresql can support bulk row fetching,
> which allow multiple records to be retrieved at once during a single fetch,
> rather than retrieving one record at a time?

Well, libpq will return a whole resultset. If that happens to contain
multiple rows it gets multiple rows.

Perhaps you should state more clearly what your problem is.

Hope this helps,

--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> There are 10 kinds of people in the world, those that can do binary
> arithmetic and those that can't.

Re: Bulk row fetching

От
"Carmen Wai"
Дата:
I want to implement a similar mechanism as bulk row fetching in MFC ODBC
classes for postgresql. For the very large record sets, it can fetch the
first (let say) 100 records. After that, it can automatically fetch the next
100 records WITHOUT executing the SQL statement again, it will save lots of
memory resouce / time.

I only find that postgresql support : select * from table_name limit N
offset M, but if I do it in this way, the DB need multiple execution which
will take up lots of time.

Do anyone gets any idea?


> > Hello:
> >
> > Do anyone know whether libpq of postgresql can support bulk row
>fetching,
> > which allow multiple records to be retrieved at once during a single
>fetch,
> > rather than retrieving one record at a time?
>
>Well, libpq will return a whole resultset. If that happens to contain
>multiple rows it gets multiple rows.
>
>Perhaps you should state more clearly what your problem is.
>
>Hope this helps,
>
>--
>Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> > There are 10 kinds of people in the world, those that can do binary
> > arithmetic and those that can't.




_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


Re: Bulk row fetching

От
Tom Lane
Дата:
"Carmen Wai" <wai_carmen@hotmail.com> writes:
> I want to implement a similar mechanism as bulk row fetching in MFC ODBC
> classes for postgresql. For the very large record sets, it can fetch the
> first (let say) 100 records. After that, it can automatically fetch the next
> 100 records WITHOUT executing the SQL statement again, it will save lots of
> memory resouce / time.

> I only find that postgresql support : select * from table_name limit N
> offset M, but if I do it in this way, the DB need multiple execution which
> will take up lots of time.

Use a cursor.

            regards, tom lane

Re: Bulk row fetching

От
Joe Conway
Дата:
Carmen Wai wrote:
>
> I want to implement a similar mechanism as bulk row fetching in MFC ODBC
> classes for postgresql. For the very large record sets, it can fetch the
> first (let say) 100 records. After that, it can automatically fetch the
> next 100 records WITHOUT executing the SQL statement again, it will save
> lots of memory resouce / time.
>
> I only find that postgresql support : select * from table_name limit N
> offset M, but if I do it in this way, the DB need multiple execution
> which will take up lots of time.
>
> Do anyone gets any idea?

It always helps to start with the manual ;-)

See:
   http://www.postgresql.org/idocs/index.php?libpq-example.html
for an example which uses a cursor. Instead of "FETCH ALL in mycursor",
you can do something like "FETCH 100 in mycursor". See:
   http://www.postgresql.org/idocs/index.php?sql-fetch.html
for more on FETCH. See:
   http://www.postgresql.org/idocs/index.php?sql-declare.html
for more on declaring a cursor.

HTH,

Joe