Client-server communication for FETCH
| От | Tim Fors |
|---|---|
| Тема | Client-server communication for FETCH |
| Дата | |
| Msg-id | CAOjiQ0C7NEV9ZBFxbM6KgXnzquaUY3MrN1x8vz_tv7uXac0UwQ@mail.gmail.com обсуждение исходный текст |
| Ответы |
Re: Client-server communication for FETCH
|
| Список | pgsql-performance |
Hello community,
I have a simple C program using libpq V18 to FETCH one row at a time (see below). Does the server send multiple rows to the client where they are cached for satisfying the FETCH statements, or does it just send one row at a time since that's all that each FETCH statement is asking for? If it's sending multiple rows at a time, is there some way that I can observe this e.g. some kind of trace info that would show it? Or where in the libpq source would I look to see how the client is retrieving rows from the server?
I have done extensive searching to try and find the definitive answer to this. The searches indicate that libpq supports the concept of a client-side cursor, where it has a cache of rows sent by the server and uses that cache to perform each FETCH, but I'd like to be able to verify whether this is true or not.
Thanks,
Tim
res = PQexec(conn, "DECLARE cur CURSOR FOR select * from table1");
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
printf("DECLARE CURSOR failed: %s", PQerrorMessage(conn));
PQclear(res);
exit(1);
}
PQclear(res);
res = PQexec(conn, "FETCH in cur");
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
printf("FETCH failed: %s", PQerrorMessage(conn));
PQclear(res);
exit(1);
}
PQclear(res);
res = PQexec(conn, "FETCH in cur");
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
printf("FETCH failed: %s", PQerrorMessage(conn));
PQclear(res);
exit(1);
}
if (PQresultStatus(res) != PGRES_COMMAND_OK)
{
printf("DECLARE CURSOR failed: %s", PQerrorMessage(conn));
PQclear(res);
exit(1);
}
PQclear(res);
res = PQexec(conn, "FETCH in cur");
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
printf("FETCH failed: %s", PQerrorMessage(conn));
PQclear(res);
exit(1);
}
PQclear(res);
res = PQexec(conn, "FETCH in cur");
if (PQresultStatus(res) != PGRES_TUPLES_OK)
{
printf("FETCH failed: %s", PQerrorMessage(conn));
PQclear(res);
exit(1);
}
В списке pgsql-performance по дате отправления: