3 Replies Latest reply on Jul 10, 2002 4:32 PM by dsundstrom

    Postgres + home.create()

    carlos.grahl

      Hi all!!

      Firstly, thank you for all replies to my other questions! :-))

      Now, a new one:

      I've installed successfully JBoss 3.0 + PostgreSQL. Then, I made three very simple entity beans (CMP), and a session bean which reads a text file and create the entity beans according to the data read. (With this, I import my text file to PostgreSQL database).

      Here is the code of the Session bean (some code ommited, leave only the relevant parts):

      tabmarhome = (TabMarHome) PortableRemoteObject.narrow(ctx.lookup("TabMar"), TabMarHome.class);
      BufferedReader in = new BufferedReader(new FileReader("c:\\eclipse\\workspace\\apuracao\\tabmar.dat"));
      String s = new String();
      while((s = in.readLine())!= null) {
      StringTokenizer st = new StringTokenizer(s, ",");
      while (st.hasMoreTokens()) {
      codesc = Integer.parseInt(st.nextToken());
      datmar = Integer.parseInt(st.nextToken());
      hormar = Integer.parseInt(st.nextToken());
      tabmarhome.create(codesc, datmar, hormar);
      }
      in.close();
      }

      When I look at the server log, JBoss made 2 SQL commands for every tabmarhome.create():

      1) Select count(*) from Tabmar where....
      2) Insert into Tabmar values(...)

      Is that correct?

      There's no way to ommit the "select count(*).." before the Insert? It's very time-expensive to do that.. And the performance is poor..

      Any ideas?

      Thank you in advance.

      Carlos Augusto Grahl

        • 1. Re: Postgres + home.create()
          joelvogt

          Just guessing off the top of my head you may want to have a look at the transaction settings you are using

          • 2. Re: Postgres + home.create()
            carlos.grahl

            I already tried "bean" and "container" and, on the container params: Required, RequiresNew and Mandatory. Always the same result (I mean: Select Count (*) + Insert)...

            Other idea?

            Carlos

            • 3. Re: Postgres + home.create()
              dsundstrom

              No, there is no way to omit the select (*). It will be configurable in a future release, but it is not a high priority. BTW, have you tested you application to be sure that it is an expensive call. I get a lot of complaints about stuff being slow from people who have not tested the application (and don't do a micro benchmark, holistic benchmarks are the only true test).