Обсуждение: Not clear on what PQgetResult does
I don't understand in what sense PQgetResult is asynchronous. Obviously PQsendQuery returns immediately and apparently PQgetResult() allows me to get separate results from multiple queries submitted together, but... Let's say I have a table with 1,000,000 rows and I PQsendQuery() a query to get them all. When I call PQgetResult() the first time, will it block until all 1,000,000 are ready, or will it send back everything that's ready at the time I call it? If the latter, is pgtcl's pg_getresult supposed to work the same way?
David Rysdam <drysdam@ll.mit.edu> writes: > I don't understand in what sense PQgetResult is asynchronous. It isn't. You can use it in an asynchronous client, but the way you do that is by not calling it until PQisBusy says you can (which means the whole result has arrived, and you're just calling PQgetResult to get hold of it). > If the latter, is pgtcl's pg_getresult supposed to work the same way? Dunno ... there was no such command last time I looked at pgtcl. regards, tom lane
Tom Lane wrote: >David Rysdam <drysdam@ll.mit.edu> writes: > > >>I don't understand in what sense PQgetResult is asynchronous. >> >> > >It isn't. You can use it in an asynchronous client, but the way you do >that is by not calling it until PQisBusy says you can (which means the >whole result has arrived, and you're just calling PQgetResult to get >hold of it). > So there's no way to have libpq return partial results before they are all ready? If I may, I would like to express some degree of incredulity. Even the version of Sybase I'm using does this right and it's from 1997!
> > Let's say I have a table with 1,000,000 rows and I > PQsendQuery() a query > to get them all. When I call PQgetResult() the > first time, will it > block until all 1,000,000 are ready, or will it send > back everything > that's ready at the time I call it? > > If the latter, is pgtcl's pg_getresult supposed to > work the same way? > pg_getresult really is just a wrapper around PQgetResult, so it should behave the same. See the README.async in pgtcl if you want more info on async with pgtcl. --brett --brett __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com
> >> >> It isn't. You can use it in an asynchronous client, but the way you do >> that is by not calling it until PQisBusy says you can (which means the >> whole result has arrived, and you're just calling PQgetResult to get >> hold of it). >> > So there's no way to have libpq return partial results before they are > all ready? > > If I may, I would like to express some degree of incredulity. Even > the version of Sybase I'm using does this right and it's from 1997! I am sure we would welcome a patch ;)) Sincerely, Joshua D. Drake > > ---------------------------(end of broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match
Joshua D. Drake wrote: >> >>> >>> It isn't. You can use it in an asynchronous client, but the way you do >>> that is by not calling it until PQisBusy says you can (which means the >>> whole result has arrived, and you're just calling PQgetResult to get >>> hold of it). >>> >> So there's no way to have libpq return partial results before they >> are all ready? >> >> If I may, I would like to express some degree of incredulity. Even >> the version of Sybase I'm using does this right and it's from 1997! > > I am sure we would welcome a patch ;)) To be honest, this is almost enough to drive me away from PG. But I like everything else about it, so I could perhaps give a patch a whirl. Or are there underlying server reasons why this won't work?
> > To be honest, this is almost enough to drive me away from PG. But I > like everything else about it, so I could perhaps give a patch a > whirl. Or are there underlying server reasons why this won't work? I thought (I could be wrong) that tom said that the support was in the protocol but that libpq did not support it, so I would guess there is no reason except that there is no patch. Sincerely, Joshua D. Drake > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend
David Rysdam <drysdam@ll.mit.edu> writes: > To be honest, this is almost enough to drive me away from PG. But I > like everything else about it, so I could perhaps give a patch a whirl. > Or are there underlying server reasons why this won't work? Have you bothered to read the preceding discussion you were pointed at? http://archives.postgresql.org/pgsql-interfaces/2005-11/index.php regards, tom lane
David Rysdam wrote: > Joshua D. Drake wrote: > > >>>It isn't. You can use it in an asynchronous client, but the way you do > >>>that is by not calling it until PQisBusy says you can (which means the > >>>whole result has arrived, and you're just calling PQgetResult to get > >>>hold of it). > >>> > >>So there's no way to have libpq return partial results before they > >>are all ready? > >> > >>If I may, I would like to express some degree of incredulity. Even > >>the version of Sybase I'm using does this right and it's from 1997! > > > >I am sure we would welcome a patch ;)) > > To be honest, this is almost enough to drive me away from PG. If you are in need of partial results you may as well use a cursor and fetch from it, a bunch at a time. > Or are there underlying server reasons why this won't work? This topic was discussed four days ago I think ... look for a thread with subject "Incremental results from libpq" on the archives of this list. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support
David Rysdam wrote: > Joshua D. Drake wrote: > > >> > >>> > >>> It isn't. You can use it in an asynchronous client, but the way you do > >>> that is by not calling it until PQisBusy says you can (which means the > >>> whole result has arrived, and you're just calling PQgetResult to get > >>> hold of it). > >>> > >> So there's no way to have libpq return partial results before they > >> are all ready? > >> > >> If I may, I would like to express some degree of incredulity. Even > >> the version of Sybase I'm using does this right and it's from 1997! > > > > I am sure we would welcome a patch ;)) > > To be honest, this is almost enough to drive me away from PG. I think you should return to Sybase as soon as you can! :-) Seriously, look at the current TODO list and the issues involved. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001+ If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania19073
Alvaro Herrera wrote: > David Rysdam wrote: > > Joshua D. Drake wrote: > > > > >>>It isn't. You can use it in an asynchronous client, but the way you do > > >>>that is by not calling it until PQisBusy says you can (which means the > > >>>whole result has arrived, and you're just calling PQgetResult to get > > >>>hold of it). > > >>> > > >>So there's no way to have libpq return partial results before they > > >>are all ready? > > >> > > >>If I may, I would like to express some degree of incredulity. Even > > >>the version of Sybase I'm using does this right and it's from 1997! > > > > > >I am sure we would welcome a patch ;)) > > > > To be honest, this is almost enough to drive me away from PG. > > If you are in need of partial results you may as well use a cursor and > fetch from it, a bunch at a time. Right, this is the standard way. > > Or are there underlying server reasons why this won't work? > > This topic was discussed four days ago I think ... look for a thread > with subject "Incremental results from libpq" on the archives of this > list. That thread has already been condensed into a TODO entry. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001+ If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania19073