pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jerome Raupach <jraupach@intelcom.fr>
To: pgsql-hackers@postgresql.org
To: pgsql-sql@postgresql.org
To: pgsql-general@postgresql.org
Subject: [Fwd: Optimization in C]
Date: Fri, 18 Aug 2000 10:14:07 +0200
Message-ID: <399CF04F.6BC4226F@intelcom.fr> (raw)

 
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.

view thread (2+ messages)  latest in thread

Message-ID: <399CF04F.6BC4226F@intelcom.fr>
Permalink:  ../399CF04F.6BC4226F@intelcom.fr/
Also on:    postgresql.org/message-id/399CF04F.6BC4226F@intelcom.fr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: jraupach@intelcom.fr, pgsql-hackers@postgresql.org, pgsql-general@postgresql.org
  Subject: Re: [Fwd: Optimization in C]
  In-Reply-To: <399CF04F.6BC4226F@intelcom.fr>
  References: <399CF04F.6BC4226F@intelcom.fr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox