Received: from primaire.intelcom.fr (primaire.intelcom.fr [194.250.33.1]) by hub.org (8.10.1/8.10.1) with ESMTP id e7I8EMm95269; Fri, 18 Aug 2000 04:14:22 -0400 (EDT) Received: from volvo.intelcom.fr ([192.168.160.20]) by primaire.intelcom.fr (8.8.8+Sun/8.8.8) with SMTP id KAA24422; Fri, 18 Aug 2000 10:14:12 +0200 (MET DST) Received: from intelcom.fr by volvo.intelcom.fr (SMI-8.6/SMI-SVR4) id KAA10736; Fri, 18 Aug 2000 10:14:07 +0200 Message-ID: <399CF04F.6BC4226F@intelcom.fr> Date: Fri, 18 Aug 2000 10:14:07 +0200 From: Jerome Raupach X-Mailer: Mozilla 4.74 [en] (X11; U; SunOS 5.5 sun4d) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-hackers@postgresql.org, pgsql-sql@postgresql.org, pgsql-general@postgresql.org Subject: [Fwd: Optimization in C] Content-Type: multipart/mixed; boundary="------------42956263FBFE15D13055EB2A" X-Archive-Number: 200008/406 This is a multi-part message in MIME format. --------------42956263FBFE15D13055EB2A Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit --------------42956263FBFE15D13055EB2A Content-Type: message/rfc822 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Mozilla-Status2: 00000000 Message-ID: <399C041B.85D480ED@intelcom.fr> Date: Thu, 17 Aug 2000 17:26:19 +0200 From: Jerome Raupach X-Mailer: Mozilla 4.74 [en] (X11; U; SunOS 5.5 sun4d) X-Accept-Language: en MIME-Version: 1.0 To: pgsql-hackers@postgresql.org Subject: Optimization in C Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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. --------------42956263FBFE15D13055EB2A--