Optimization in C - Mailing list pgsql-hackers

From Jerome Raupach
Subject Optimization in C
Date
Msg-id 399C041B.85D480ED@intelcom.fr
Whole thread Raw
Responses Re: Optimization in C  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-hackers
This solution isn't good when there are +10000 tuples in the table, it's
slowly...
anybody can help me ? :

       string = "SELECT service, noeud, rubrique FROM table" ;       res = PQexec( conn, string.data() ) ;       if (
(!res) || (status = PQresultStatus( res ) !=
 
PGRES_TUPLES_OK) )       {               cerr << _ERROR << "Problem SELECT ! " << endl ;               cerr << _ERROR
<<"Error : " << PQresStatus( status ) <<
 
endl ;               cerr << _ERROR << "Error : " << PQresultErrorMessage(
res ) << endl ;               PQclear( res ) ;       }       else       {               for (int m=0; m < PQntuples(
res); m++)               {                       service = PQgetvalue( resultat1, m, 0 ) ;                       noeud
=PQgetvalue( resultat1, m, 1 ) ;                       rubrique = PQgetvalue( resultat1, m, 2 ) ;
 
                       commande = "SELECT SUM(date) FROM table WHERE
service='" + service +
"' AND noeud='" + noeud + "' AND rubrique='"+ rubrique + "'" ;                       res1 = PQexec( conn, string.data()
);                       if ( (! res1) || (status = PQresultStatus( res1
 
) != PGRES_TUPLES_OK)
)                       {                               cerr << _ERROR << "Problem SUM ! " <<
endl ;                               cerr << _ERROR << "Error : " <<
PQresStatus( status ) << endl ;                               cerr << _ERROR << "Error : " <<
PQresultErrorMessage( res1 ) << endl
;                               PQclear( res1 ) ;                       }                       else
  {                               cout << _TRACE << "SUM ok." << endl ;                               PQclear( res1 ) ;
                     }               }               PQclear( res ) ;       }
 

Thanks. jerome.


pgsql-hackers by date:

Previous
From: Karel Zak
Date:
Subject: Re: [GENERAL] Regression Tests
Next
From: "Ross J. Reedstrom"
Date:
Subject: Re: Large # of Tables, Getting ready for the enterprise