ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Problems with a logical file?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Re: Problems with a logical file?

    This is the code. Very simple code.

    PHP Code:
    Descripcion de fichero
         c     clau2         klist
         c                   kfld                    clpos1
         c                   kfld                    clpos2
         c                   kfld                    clapel
         
          
    Llenamos valores
         c                   
    eval      clpos1 w_pos1
         c                   
    eval      clpos2 w_pos2
         c                   
    eval      clapel w_apel
         
         c     clau2         setll     lmclie4                            
         c                   read      lmclie4                                99

          
    Si hemos llegado a otro CP activamos 99 para salir
         c                   
    IF        CLPOS1 1000 CLPOS2 
         
    c                                W_POS1 1000 W_POS2
         c                   
    EVAL      *IN99 = *ON
         c                   
    ENDIF

         
    c                   dow       *in99 = *off
         c                   
    if        %trim(w_apel) =  
         
    c                               %subst(clapel:1:%len(%trim(w_apel)))
         
    c                               and clpobl w_pobl
         c                   exsr      add_sfl
         c                   
    ENDIF
         
    c                   read      lmclie4                                99

          
    Si hemos llegado a otro CP activamos 99 para salir
         c                   
    IF        CLPOS1 1000 CLPOS2 
         
    c                                W_POS1 1000 W_POS2
         c                   
    EVAL      *IN99 = *ON
         c                   
    ENDIF

         
    c                   ENDDO 
    This is the DDS

    PHP Code:
                     R RMCLIE                    PFILE(CLIENTS)                     
                                                                                  
                    
    K CLPOS1                                                      
                    K CLPOS2                                                      
                    K CLAPEL 
    I'm sure (more or less) is not problem of the code.
    Last edited by FaStOnE; November 5, 2010, 11:36 AM.

    Comment


    • #17
      Re: Problems with a logical file?

      Oh Shiznit, that needs to be rewritten:

      First, create a variable to hold the calculation of CLPOS1 * 1000 + CLPOS2. You are blowing a lot of CPU cycles by performing that calculation on every record read.

      Second, can you use a READE instead of READ? That would greatly reduce the number of records read in the do loop.

      Third, if you can use a READE, then create an additional index over CLPOBL. Then setll on the current key plus clpoble, and do a reade, and remove the clpobl = w_pobl in the calcs.

      Fourth, if you cant do a reade, then swap the statement:
      Code:
      [SIZE=2][FONT=Courier New][COLOR=#0000bb]c                   [/COLOR][COLOR=#007700]if        %[/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]w_apel[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) =  [/COLOR][/FONT][/SIZE]
      [SIZE=2][FONT=Courier New][COLOR=#0000bb]c                               [/COLOR][COLOR=#007700]%[/COLOR][COLOR=#0000bb]subst[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]clapel[/COLOR][COLOR=#007700]:[/COLOR][COLOR=#0000bb]1[/COLOR][COLOR=#007700]:%[/COLOR][COLOR=#0000bb]len[/COLOR][COLOR=#007700](%[/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]w_apel[/COLOR][/FONT][FONT=Courier New][COLOR=#007700])))[/COLOR][/FONT][/SIZE]
      [SIZE=2][FONT=Courier New][COLOR=#0000bb]c                               [/COLOR][COLOR=#007700]and [/COLOR][COLOR=#0000bb]clpobl [/COLOR][COLOR=#007700]= [/COLOR][/FONT][COLOR=#0000bb][FONT=Courier New]w_pobl[/FONT][/COLOR][/SIZE]
      To:

      Code:
      [COLOR=#0000bb][FONT=Courier New][SIZE=2]c                   [/SIZE][COLOR=#007700][SIZE=2]if        [COLOR=#0000bb]clpobl [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb][FONT=Courier New]w_pobl AND[/FONT][/COLOR][/SIZE]
      [SIZE=2]                              %[/SIZE][/COLOR][SIZE=2][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]w_apel[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#007700]) =  [/COLOR][/SIZE][/FONT]
      [SIZE=2][FONT=Courier New][COLOR=#0000bb]c                             [/COLOR][COLOR=#007700]%[/COLOR][COLOR=#0000bb]subst[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]clapel[/COLOR][COLOR=#007700]:[/COLOR][COLOR=#0000bb]1[/COLOR][COLOR=#007700]:%[/COLOR][COLOR=#0000bb]len[/COLOR][COLOR=#007700](%[/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]w_apel[/COLOR][/FONT][FONT=Courier New][COLOR=#007700])))[/COLOR][/FONT][/SIZE]
      [/COLOR]
      It's much faster for the sysem to check for LPOBL = W_POBL than for it to trim and check substrings. If this first part fails, it never has to do the trims and substrings.


      This could simply be a performance related issue, where one job brings in the records needed for the do loop, and another job can use those same records in memory if it executes soon after the first search. If another search is performed, a totally new set of records has to be brought in from disk into memory.
      Last edited by MichaelCatalani; November 5, 2010, 12:10 PM.
      Michael Catalani
      IS Director, eCommerce & Web Development
      Acceptance Insurance Corporation
      www.AcceptanceInsurance.com
      www.ProvatoSys.com

      Comment


      • #18
        Re: Problems with a logical file?

        Originally posted by MichaelCatalani View Post
        Oh Shiznit, that needs to be rewritten:
        Shiznit??


        Hahahahahahaha.....

        Comment


        • #19
          Re: Problems with a logical file?

          If you carry out what Michael suggests, pls tell us whether the program runs better now.
          Philippe

          Comment


          • #20
            Re: Problems with a logical file?

            Originally posted by Mercury View Post
            If you carry out what Michael suggests, pls tell us whether the program runs better now.
            I dont know if it will fix the apparant problem with the long initial delays, but I can promise you it will cut out an arseload of CPU cycles.
            Michael Catalani
            IS Director, eCommerce & Web Development
            Acceptance Insurance Corporation
            www.AcceptanceInsurance.com
            www.ProvatoSys.com

            Comment


            • #21
              Re: Problems with a logical file?

              I have submitted Shiznit to Merriam-Websters .... hopefully included in the next edition.

              -----------------------------------------------------------------------------------

              Shiznit verb \Shiznit\

              Shiznitted | Shiznitting | Shizzed

              Definition of SHIZNIT

              transitive verb
              1. To code with efficiency and precision <Who shiznitted this code, it's awesome>
              2. To improve a current piece of program code <To shiznit the upload routine>
              3. To do the best that can be done <He shizzed the whole deal>
              4. Expletive, to suffer some misfortune that is not pleasant <Shiznit!> as if to say "That could have been done better, wish I'd shizzed it"
              intransitive verb
              Shiznitter noun


              Examples of SHIZNIT
              • We Shiznitted the upload module.
              • Who is going to Shiznit the interface?
              • It was running slow so i shizzed it up a bit.
              Origin of SHIZNIT
              • Sound made by the driver of an overpowered Dodge Viper on hitting the power band on a change up at the same time as hitting a bump in the road, while trying to drink a hot coffee, and getting coffee up nostrils.
              • Originally posted by MichaelCatalani View Post
                "I dont know if it will fix the apparant problem with the long initial delays, but I can promise you it will cut out an arseload of CPU cycles"
              Related to SHIZNIT
              Synonyms: optimise, improve
              Last edited by gcraill; November 6, 2010, 12:28 AM.
              Greg Craill: "Life's hard - Get a helmet !!"

              Comment


              • #22
                Re: Problems with a logical file?

                R o t f l !
                Philippe

                Comment


                • #23
                  Re: Problems with a logical file?

                  Hi.

                  I made the chandes that Michael said, and it not work. The result is the same (maybe 9 secons ).

                  I rewrote my code using sql and it works corretly. The delay is acceptable, less than 2 seconds.

                  But the problem persists, but almos inperceptible. The first time takes less than 2 seconds, and the rest of times is inmediate.

                  thanks for all answers and helps.

                  Comment


                  • #24
                    Re: Problems with a logical file?

                    Now THAT'S funny! I don't care WHO you are!

                    Comment


                    • #25
                      Re: Problems with a logical file?

                      I close the post.

                      for additional information:

                      brojoatt@hotmail.com



                      Alberto

                      Comment

                      Working...
                      X