Can you please tell us how set this prefetch attribute in following lines.

From: M Tarkeshwar Rao <m(dot)tarkeshwar(dot)rao(at)ericsson(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Can you please tell us how set this prefetch attribute in following lines.
Date: 2019-10-17 11:16:29
Message-ID: VI1PR0701MB271869EC2BEDD69E1D0CEC86AE6D0@VI1PR0701MB2718.eurprd07.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-performance

Hi all,

How to fetch certain number of tuples from a postgres table.

Same I am doing in oracle using following lines by setting prefetch attribute.

For oracle
// Prepare query
if( OCIStmtPrepare( myOciStatement, myOciError, (text *)aSqlStatement,
// Get statement type
OCIAttrGet( (void *)myOciStatement, OCI_HTYPE_STMT, &statement_type, 0, OCI_ATTR_STMT_TYPE, myOciError );
// Set prefetch count
OCIAttrSet( myOciStatement, OCI_HTYPE_STMT, &prefetch, 0, OCI_ATTR_PREFETCH_ROWS, myOciError );
// Execute query
status = OCIStmtExecute( myOciServerCtx, myOciStatement, myOciError, iters, 0, NULL, NULL, OCI_DEFAULT );

For Postgres

Can you please tell us how set this prefetch attribute in following lines. Is PQexec returns all the rows from the table?

mySqlResultsPG = PQexec(connection, aSqlStatement);
if((PQresultStatus(mySqlResultsPG) == PGRES_FATAL_ERROR ) || (PQstatus(connection) != CONNECTION_OK)){}
if ((PQresultStatus(mySqlResultsPG) == PGRES_COMMAND_OK) || (PQresultStatus(mySqlResultsPG) == PGRES_TUPLES_OK))
{
myNumColumns = PQnfields(mySqlResultsPG);
myTotalNumberOfRowsInQueryResult = PQntuples(mySqlResultsPG);
myCurrentRowNum = 0 ;
}

Regards

Tarkeshwar

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Laurenz Albe 2019-10-17 11:25:36 Re: A little confusion about JSON Path
Previous Message Laurenz Albe 2019-10-17 11:09:14 Re: PostgreSQL memory usage

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro Horiguchi 2019-10-17 11:28:12 Re: Proposal: Make use of C99 designated initialisers for nulls/values arrays
Previous Message Amit Kapila 2019-10-17 11:14:41 Re: Ordering of header file inclusion

Browse pgsql-performance by date

  From Date Subject
Next Message Reid Thompson 2019-10-17 16:18:42 Re: Can you please tell us how set this prefetch attribute in following lines.
Previous Message Tom Lane 2019-10-17 09:04:32 Re: Change in CTE treatment in query plans?