Performance question!

Hello guys,

I’m new using Natural/ADABAS and I tried to make one question for another language without
unsuccessfully (sad day).

I’ve seen many topics talking about READ and FIND but in this specifc case I thought READ wouldn’t be faster than FIND. I will describe the question below and I will be really happy if anyone can help me today! See ya!


Develop a routine that returns the products launched in a given period that are of a certain type.

It must be read the product file, with the input parameter type of product (see list) and the desired release period - beginning and end date of the first record (confirmed).

The result should be sorted by launch date and the end of each date found will be presented a totalizing. At the end of the report should be the general totalizer.

It is extremely important to note that there is a super-descriptor field formed by the REG-TYPE + REG-DTCONFIRMADO descriptors and may be determined that any other fields may become descriptors if necessary.

The focus and priority of this issue is the query efficiency trying to use the lowest cost to the bank (ADABAS), justify your answer.

TABLE OF PRODUCTS = DB096552-YRE-AS

*FIELDS THAT WILL BE USED

REG-TYPE
REG-DTCONFIRMADO
REG-NAME
REG-IDENT

  • How the layout should be!
  • MAP
    PROGRAM: * PROGRAM
    PAGES: (NUMBER OF PAGES)
    DATE:

PRODUCT REPORT LAUNCHED BETWEEN THE PERIOD The

IDENT PRODUCT NAME

TOTAL PRODUCT LAUNCHED IN THE DAY FOUND =>

I was thinking about something like that:


DEFINE DATA LOCAL
1 PRODUCTS VIEW OF DB096552-YRE-A
  2 REG-TYPE(N02) => ONLY TO LET YOU KNOW THE SIZE
  2 REG-DTCONFIRMADO (N08)
  2 CAD-NAME (A30)
  2 CAD-IDENT (A07)


1 #TYPE (A8)
1 #DT-INT (N08)
1 #DT-END (N08)
END-DEFINE
#PROGRAM := *PROGRAM
INPUT USING MAP 'M01'
READ PRODUCTS BY SUPER-REG-TYPE-REG-IDENT
    STARTING FROM <super-descriptor> <- ( I don't know how to insert the value of super-descriptor here, but maybe is like that 'SUPER-REG-TYPE-REG-IDENT')
  IF REG-DTCONFIRMADO GE #DT-INIT AND REG-DTCONFIRMADO LE #DT-END
  . . .
  ESCAPE TOP
  END-READ
END

Some additional information that would be useful:

Am I correct that the super SUPER-REG-TYPE-REG-IDENT concatenates the reg-type and the reg-ident? If so, how many records might satisfy a given reg-type-reg-ident?

If the number is small, it is probably the case that the difference between FIND and READ will be insignificant (doesn’t matter very much).

If the number is large, how many records will satisfy the specified date range? If the answer is most of the records for a given type-ident will be in the specified date range, there will be little difference between FIND and READ.

A super descriptor type-ident and dtconfirmado “might” be useful, depending on the answer to my last question (immediately above). Then you could do a READ by reg-type-reg-ident-reg-confirmado.

Any information you have on the answers to the above questions would help the discussion.

Yes you are right! That’s one big problems for me, as I’m new in the language, I don’t even know how to do it. =/ sorry about that.

I don’t know how many records I will have to find out, but I want to know how is the best way to make this search with many records, so I think would be great if someone could show me how to do it right. Another important point is that I will need to have the recods organized, but I think as I’m using a super it will already be organized.

I don’t know how to paginate using the language, in other languages I’ve been working around normally I get 50 per page, but in this case I think that’s ok to show all of them, feel free to show me the best way to do it.

If you prefer you could change the vars to make easier to understand.

The point is, I want to see the best results I can get using READ and FIND, the results must be ordenated, so I think it is an important point, specially if we use READ (so far I don’t know how to use it right).

The program has to check the products by type and range of dates informed by the user, them the data has to be ordenated by CAD-IDENT and at the end of each one it has to display a counter with how many has per date. At the end of report it will display how many products we have, but only that has the same type informed and how many per date.

Sorry for my English, still learning as well.

Well… I will try to change to see if makes the job eassier.

See bellow:

Develop a routine that returns all vehicles emplacados in a certain period, a particular type of vehicle.

For each one, you need to read the vehicle file, the input parameter type of the vehicle and the desired period of time: dt-init and dt-end (license plate).

The result should be sorted by the date of the license plate. At the end of each date found, it must be presented a totalizing and the end of the report should be a general totalizer.

I would like to know which fields I should become a super-descriptor and why this is the best option to perform an optimized search, thus increasing the performance of ADABAS.

The program should look like that:

PROGRAM: *PROGRAM
PAGE: (DON’T KNOW HOW TO DO IT)

RELATION OF THE PERIOD vehicles licensed during 99/99/9999 A 99/99/9999 BY THE TYPE?: “XXXXXXXX”

PLACA NOME PROPRIETARIO

==================================================================================================================================================

TOTAL DE VEICULOS ENCONTRADOS EMPLACADOS NO DIA 99/99/9999 => xxx
*

  • Tipes of vehicles :
  • 1 = VEHNICHICE
  • 2 = ‘CICLOMOTO’
  • 3 = ‘MOTONETA’
  • 4…

Haroldo,

FIND versus READ, as I indicated in my earlier post, is a function of many things. There is no simple answer which says one is better than the other. To answer such a question you need to know quite a bit about Adabas, Natural, and, more than a little about the characteristics of the data (which you might be able to get from a business analyst).

Most importantly, you cannot answer your FIND versus READ question without knowing more about Adabas and Natural.
Explain to the company you work for that you require education in both Adabas and Natural.

Sorry for so many questions, I’m really “noob” with the language.

I don’t work for any company that uses Natural and ADABAS, I’m trying to learn it by myself.

One possible solution that I thought was the code bellow but I’m not right if the IF statments are totally right.

DEFINE DATA LOCAL
1 VEICULOS VIEW OF DB06500-DETRAN-VEICULOS
  2 CAD-01
  2 CAD-DTPREE
  2 CAD-NOME
  2 CAD-PLACA
  2 CAD-CODTIPO-DTPREE
* DEFINE VARIAVEIS LOCAIS
1 #DT-INIT (N08)
1 #DT-END (N08)
1 #CT (N07)
1 #CT-TOT (N07)
1 #DT-TYPE (N10)
1 REEFINE #DT-TYPE
  2 #DATA (N08)
  2 #TYPE (N02)
1 #DT-TEMP (N08)
*
END-DEFINE
RESET #CT #CT-TOT
INPUT 'WRITE DOWN THE TYPE OF VEHICLE....:' #TYPE
INPUT 'WRITE DOWN THE INITIAL DATE.......:' #DT-INIT
  IMPUT 'WRITE DOWN THE LAST DATE..........:' #DT-END
*
MOVE #DT-INIT TO #DATA
MOVE #DT-INIT TO #DT-TEMP
READ VEICULOS BY CAD-CODTIPO-DTPREE EQ #DT-TYPE
  IF CAD-DTPREE BT #DT-TEMP
  WRITE 'TOTAL VEHICLE FOUND AND HAD THE LICENSE PLATE MADE IN DATE ' #DT-TEMP ' -> ' #CT
  #CT-TOT := #CT-TOT + #CT
  RESET #CT
  MOVE CAD-DTPREE TO #DT-TEMP
  END-IF
  IF CAD-DTPREE BT #DT-END
    SCAPE BOOTOM
  END-IF
  WRITE CAD-PLACA '           '  CAD-NOME
  ADD 1 TO #CT
  END-READ
  WRITE 'TOTAL VEHICLES LICENSED DURING THE PERIOD FROM ' #DT-INIT ' TO ' #DT-END ' -> ' #CT-TOT
END

This one is a no-brainer. You need to retrieve a set of records based on a range of key values, in key sequence. FIND can’t (efficiently) sort records.

You need to READ with a superdescriptor composed of vehicle type + license date + plate number. The basic code would look like this.

DEFINE DATA LOCAL
1 VEH    VIEW VEHICLES
  2 VEH-TYPE (A1)
  2 LIC-DATE (D)
  2 LICENSE (A7)
  2 VIN (A16)
*
1 #BEG-DEF
  2 #TYP (A1)
  2 #LDATE (D)
  2 #LIC (A7)      1 REDEFINE #BEG-DEF
  2 #BEG (A12)
1 #END-DEF
  2 #TYP (A1)
  2 #LDATE (D)
  2 #LIC (A7)      INIT FULL LENGTH <H'FF'>
                   1 REDEFINE #END-DEF
  2 #END (A12)
END-DEFINE
*
INPUT 'Vehicle Type:' #BEG-DEF.#TYPE
    / '  Begin Date:' #BEG-DEF.#LDATE
    / '    End Date:' #END-DEF.#LDATE
ASSIGN #END-DEF.#TYPE = #BEG-DEF.#TYPE
*
READ VEH BY SD-TYP-LICDT-LIC       /* VEH-TYPE + LIC-DATE + LICENSE
       FROM #BEG
         TO #END
  DISPLAY
          VEH.LIC-DATE
          VEH.LICENSE
          VEH.VIN
END-READ
END

Then add at an AT BREAK statement for totals by date, AT END OF DATA for final totals, and a MULTI-FETCH ON clause for performance.