List:General Discussion« Previous MessageNext Message » Date:October 24 2000 6:32pm
Subject:insert too slow: how to increase the speed?
View as plain text  
I have to insert in Mysql database a lot of row:
how can I increase insert?
I 'm using C++.
Thank you in advance !

Wath do you think about:
    query << "insert into %5:table values (%q0, %q1, %2, %3, %q4)"; 
But I don't understand how can I use this: how does it works?
How can I insert row in this way?

4.7 Template Queries 
Another powerful feature of Mysql++ is being able to set up template 
queries. The following example demonstrates how to use them. This code 
is the actual code used to set up and/or reset the sample database. It 
can be found under we hope to come up with some better 
examples soon. 

#include <iostream> 
#include <sqlplus.hh> 
int main (int argc, char *argv[]) { 
  Connection connection(use_exceptions); 
  try { // the entire main block is one big try block; 
    if (argc == 1) connection.connect(""); 
    else if (argc == 2) connection.connect("",argv[1]); 
    else if (argc == 3) connection.connect("",argv[1],argv[2]); 
    else if (argc <= 4) connection.connect("",argv[1],argv[2],argv[3]); 
    // create a new object and connect based on any (if any) arguments 
    // passed to main(); 
    try { 
    } catch (BadQuery er) { 
      // if it couldn't connect to the database assume that it doesn't 
      // and try created it.  If that does not work exit with an error. 
    Query query = connection.query();  // create a new query object 
    try { // ignore any errors here 
          // we hope to make this simpler soon 
      query.execute("drop table stock"); 
    } catch (BadQuery er) {} 
    query << "create table stock  (item char(20) not null, num 
          << "weight double, price double, sdate date)"; 
    // send the query to create the table and execute it.  The 
    // RESET_QUERY tells the query object to reset it self after 
    // execution 
    query << "insert into %5:table values (%q0, %q1, %2, %3, %q4)"; 
    // set up the template query we will use to insert the data.  The 
    // parse method call is important as it is what lets the query 
    // know that this is a template and not a literal string 
    query.def["table"] = "stock"; 
    // This is setting the parameter named table to stock. 
    query.execute ("Hamburger Buns", 56, 1.25, 1.1, "1998-04-26"); 
    query.execute ("Hotdogs' Buns"   ,65, 1.1 , 1.1, "1998-04-23"); 
    query.execute ("Dinner Roles"  , 75,  .95, .97, "1998-05-25"); 
    query.execute ("White Bread"   , 87, 1.5, 1.75, "1998-09-04"); 
    // The last parameter "table" is not specified here.  Thus 
    // the default value for "table" is used which is "stock". 
  } catch (BadQuery er) { // handle any errors that may come up 
    cerr << "Error: " << er.error << endl; 
    return -1; 

insert too slow: how to increase the speed?rino.mail@libero.it24 Oct
  • RE: insert too slow: how to increase the speed?Daevid Vincent24 Oct
  • Re: insert too slow: how to increase the speed?Fredrik Kristiansen25 Oct