From: | M Tarkeshwar Rao <m(dot)tarkeshwar(dot)rao(at)ericsson(dot)com> |
---|---|
To: | "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org> |
Subject: | Can you please tell us how set this prefetch attribute in following lines. |
Date: | 2019-10-18 03:47:49 |
Message-ID: | VI1PR0701MB2718E031C9729F3047E5C339AE6C0@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
From | Date | Subject | |
---|---|---|---|
Next Message | Daulat Ram | 2019-10-18 05:59:21 | Postgres Point in time Recovery (PITR), |
Previous Message | M Tarkeshwar Rao | 2019-10-18 03:47:13 | RE: Can you please tell us how set this prefetch attribute in following lines. |
From | Date | Subject | |
---|---|---|---|
Next Message | Dilip Kumar | 2019-10-18 04:04:28 | Re: Questions/Observations related to Gist vacuum |
Previous Message | M Tarkeshwar Rao | 2019-10-18 03:47:13 | RE: Can you please tell us how set this prefetch attribute in following lines. |
From | Date | Subject | |
---|---|---|---|
Next Message | Justin Pryzby | 2019-10-18 16:15:02 | Re: Can you please tell us how set this prefetch attribute in following lines. |
Previous Message | M Tarkeshwar Rao | 2019-10-18 03:47:13 | RE: Can you please tell us how set this prefetch attribute in following lines. |