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

From: Reid Thompson <Reid(dot)Thompson(at)omnicell(dot)com>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Cc: Reid Thompson <Reid(dot)Thompson(at)omnicell(dot)com>
Subject: Re: Can you please tell us how set this prefetch attribute in following lines.
Date: 2019-10-17 16:18:42
Message-ID: f3c4040f13b1dfcca79fd2e8046d0617cbdef790.camel@omnicell.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-performance

On Thu, 2019-10-17 at 11:16 +0000, M Tarkeshwar Rao wrote:
> [EXTERNAL SOURCE]
>
>
>
> 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
>

declare a cursor and fetch

https://books.google.com/books?id=Nc5ZT2X5mOcC&pg=PA405&lpg=PA405&dq=pqexec+fetch&source=bl&ots=8P8w5JemcL&sig=ACfU3U0POGGSP0tYTrs5oxykJdOeffaspA&hl=en&sa=X&ved=2ahUKEwjevbmA2KPlAhXukOAKHaBIBcoQ6AEwCnoECDEQAQ#v=onepage&q=pqexec%20fetch&f=false

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Laurenz Albe 2019-10-17 17:05:57 Re: Can you please tell us how set this prefetch attribute in following lines.
Previous Message Luca Ferrari 2019-10-17 15:42:54 Re: Vacuum very big table - how the full vacuum works in background/internally?

Browse pgsql-hackers by date

  From Date Subject
Next Message Laurenz Albe 2019-10-17 17:05:57 Re: Can you please tell us how set this prefetch attribute in following lines.
Previous Message Alvaro Herrera 2019-10-17 15:47:47 Re: Compressed pluggable storage experiments

Browse pgsql-performance by date

  From Date Subject
Next Message Laurenz Albe 2019-10-17 17:05:57 Re: Can you please tell us how set this prefetch attribute in following lines.
Previous Message M Tarkeshwar Rao 2019-10-17 11:16:29 Can you please tell us how set this prefetch attribute in following lines.