[Monetdb-developers] Why the Speed of Mapi Lib is so lower?

peter qin peterqin1980 at gmail.com
Wed Oct 6 15:13:54 CEST 2010

Dear all,
       Yesterday,I had done a test about the speed of MonetDB.I used
the example code make a test.the red part is my adding code.
#include <mapilib/Mapi.h>
     #include <stdio.h>
     #include <stdlib.h>

     void die(Mapi dbh, MapiHdl hdl)
      if (hdl != NULL) {
       mapi_explain_query(hdl, stderr);
       do {
        if (mapi_result_error(hdl) != NULL)
         mapi_explain_result(hdl, stderr);
       } while (mapi_next_result(hdl) == 1);
      } else if (dbh != NULL) {
       mapi_explain(dbh, stderr);
      } else {
       fprintf(stderr, "command failed\n");

     MapiHdl query(Mapi dbh, char *q)
      MapiHdl ret = NULL;
      if ((ret = mapi_query(dbh, q)) == NULL || mapi_error(dbh) != MOK)
       die(dbh, ret);

     void update(Mapi dbh, char *q)
      MapiHdl ret = query(dbh, q);
      if (mapi_close_handle(ret) != MOK)
       die(dbh, ret);

     int main(int argc, char *argv[])
         Mapi dbh;
         MapiHdl hdl = NULL;
      char *name;
      char *age;

         dbh = mapi_connect("localhost", 50000, "monetdb", "monetdb",
"sql", "demo");
         if (mapi_error(dbh))
             die(dbh, hdl);

      update(dbh, "CREATE TABLE emp (name VARCHAR(20), age INT)");

      for(int i = 0;i<10000;i++)
      update(dbh, "INSERT INTO emp VALUES ('John', 23)");
     //why this cast more then serveral minutes .can you help me?

      hdl = query(dbh, "SELECT * FROM emp");

         while (mapi_fetch_row(hdl)) {
             name = mapi_fetch_field(hdl, 0);
             age = mapi_fetch_field(hdl, 1);
             printf("%s is %s\n", name, age);



Peter Qin
 peterqin1980 at gmail.com

More information about the developers-list mailing list