home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Product / Product.zip / DBDEMO.ZIP / DEMOFLS.ZIP / DBDEMO.DOC < prev    next >
Text File  |  1991-08-02  |  15KB  |  389 lines

  1.   DATABASE PERFORMANCE CONCEPTS AND TECHNIQUE DEMONSTRATION PROGRAM
  2.                         USER DOCUMENT
  3.  
  4.  
  5.  
  6. You can install this demo in one of two ways.  You can install the
  7. executables or you can compile the source from scratch.  There are
  8. slight differences in the procedure for each method.
  9.  
  10.  
  11.  
  12. DEMO INSTALLATION REQUIREMNTS
  13.  
  14.  
  15.  
  16.  
  17.  TO INSTALL THE EXECUTABLES ON THE SERVER (WITHOUT COMPILING)
  18.  
  19.  
  20. 1.  Create an ID name (BMCHUGH) with System Admin Authority.
  21.     Logon with ID name BMCHUGH.
  22.  
  23. 2.  To create the Bank Database make the current directory the directory which
  24.     contains the database build programs (REF: README file on diskette).
  25.     Unpack the Demo Database Files (DEMODB.EXE), then Type DBCREATE <enter>.
  26.     This will create the BANK database.
  27.  
  28. 3.  Unpack the demo files (DEMOFLS.EXE) in a separate directory and make that
  29.     the current directory. (REF: README file on diskette)
  30.  
  31. 4.  Run the command "SQLBIND ARIS.BND BANK"
  32.  
  33. 5.  Copy the file ARIS.DLL to the directory "\sqllib\dll" on the server.
  34.  
  35.  
  36. 6.  If you want to run the demo on the server go to step 7.  If you want
  37.     to run the demo from a requester (recommended) go to step 10 in the
  38.     section (RUN DBDEMO FROM A REQUESTER :) below.
  39.  
  40. 7.  Type DEMOBIND at the server. Now the DBDEMO program is ready to run
  41.     at the server. Type DBDEMO to start the demo. (Stop here)
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  TO COMPILE THE SOURCE CODE AND RUN DEMO
  48.  
  49.  
  50.  SYSTEM SET UP:
  51.  
  52.  
  53. 1.  A C compiler, with all the relevant environment variables set up in
  54.     the config.sys file, i.e. (assuming you are using C: drive )
  55.     SET INCLUDE must contain C:\SQLLIB;
  56.     SET LIB must contain C:\SQLLIB;
  57.  
  58. 2.  IBM OS/2 TOOLKIT should be installed with proper variables in the
  59.     config.sys.
  60.  
  61. 3.  There should be no database named BANK since that is the name that this
  62.     program uses.
  63.  
  64.  
  65.  CREATE DATABASE: (requires compiling)
  66.  
  67.  
  68.  
  69. 4.  Create an ID name (BMCHUGH) with System Admin Authority.
  70.     Logon with ID name BMCHUGH.
  71.  
  72. 5.  To create the Bank Database make the current directory the directory which
  73.     contains the database build programs (REF: README file on diskette).
  74.     Unpack the Demo Database Files, then Type DBBUILD <enter>.
  75.  
  76.  
  77.  RUN DBDEMO ON SERVER: (requires compiling)
  78.  
  79.  
  80. 6.  Make the directory containing the demo files the current directory.
  81.     (REF: README file on diskette)
  82.  
  83. 7.  To create the file ARIS.DLL, type MAKE ARIS, which creates the DLL required
  84.     for the ARI funtion. In addition ARIS.DLL is copied to the subdirectory
  85.     C:\SQLLIB\DLL.  This is valid if the machine you are compiling on
  86.     is also the database server.  Otherwise, the DLL has to be copied to
  87.     the server.
  88.  
  89. 8.  To compile the DEMO type MAKE DBDEMO.
  90.  
  91. 9.  Now the DBDEMO program is ready to run at the server. Type DBDEMO to
  92.     start the demo.
  93.  
  94.  
  95.  
  96.  RUN DBDEMO FROM A REQUESTER :
  97.  
  98.  
  99. 10. Start the communication manager, Start the database manager,
  100.     and catalog the BANK database in Query manager.
  101.  
  102. 11. Create a directory on the requester for the demo files.
  103.  
  104. 12. To run the DBDEMO program on a requester the following files
  105.     are required from the server ( .exe, .txt, .bnd,). These files
  106.     can be copied to diskette by typing CPYREQ at the server. The files
  107.     must then be copied to the requester directory created in step 11.
  108.  
  109. 13. Type DEMOBIND at the requester. Now the DBDEMO program is ready to run
  110.     at the requester. Type DBDEMO to start the demo.
  111.  
  112.  
  113. This program, written by the OS/2 EE Application Development Technical Support
  114. group in Austin, Texas, illustrates some techniques used to get better
  115. performance out of OS/2 EE Database manager.
  116.  
  117. The program consists of a Presentaion Manager interface and C language
  118. modules containing embedded SQL statements.  A table containing all the
  119. source modules, header files, text files, make and link files is shown
  120. below (appendix A).
  121.  
  122. The database used simulates a banking environment and is named BANK.
  123. The table layouts and other information about this database are shown
  124. in appendix B.
  125.  
  126. All the programs were compiled using the qualifier BMCHUGH and should
  127. be changed to your logon ID (search and replace) in all the source
  128. files. Or, you may choose to create the id BMCHUGH on your machine and
  129. leave the demo code unchanged.
  130.  
  131. All the code should reside on the requester except for the ARI
  132. procedure - ARIS.DLL, which should be copied into a subdirectory on
  133. the server which is in the LIBPATH. (check CONFIG.SYS).  All the text
  134. files (.txt) should reside in the subdirectory from which the program
  135. is to be run.
  136.  
  137.  
  138. When running demos of ARI, RECORD BLOCKING, INDEXES, or STATIC vs DYNAMIC
  139. SQL you may only have one demo screen active at any given time. (ie. If
  140. you run ARI you must close that screen before running RECORD BLOCKING).
  141.  
  142.  
  143.  
  144.                           QUERIES USED
  145.  
  146. Indices
  147.  
  148.   PERFDAT3 and PERFDAT4 are exactly the same tables except
  149.   PERFDAT4 has an index on CU_SSN.
  150.  
  151.          SELECT * FROM BMCHUGH.PERFDAT3
  152.          WHERE CU_SSN   BETWEEN  '111-11-1020' AND '111-11-1140';
  153.  
  154.          SELECT * FROM BMCHUGH.PERFDAT4
  155.          WHERE CU_SSN   BETWEEN  '111-11-1020' AND '111-11-1140';
  156.  
  157.  
  158. Static vs Dynamic:
  159.  
  160. The query was designed to be complex (to increase the PREPARE time)
  161. and to access only one row, so that the difference between dynamic and
  162. static query would be clear.  However, this DOES NOT imply that
  163. dynamic queries are always slower than static queries.  In some cases,
  164. when the database has undergone changes since the last time the application
  165. was bound, dynamic queries can take advantage of the latest statistics
  166. and run faster.
  167.  
  168. Usually, the choice between dynamic or static query is determined by
  169. application constraints, e.g., when the query is not known in
  170. advance.
  171.  
  172.         SELECT  CU_NAME, CU_SSN, S_BAL, C_ACCNUMB
  173.         FROM BMCHUGH.CUSTOMER, BMCHUGH.SAVINGS, BMCHUGH.CHECKING
  174.         WHERE CU_SSN = S_SSN AND CU_SSN > '000-00-0000'
  175.            AND  CU_SSN < '999-99-9999' AND  S_BAL > 499
  176.            AND  S_BAL < 20000 AND  C_STARTBAL > 0
  177.            AND C_STARTBAL < 10000 AND C_ENDBAL > 0
  178.            AND C_ENDBAL < 20000 AND C_STARTBAL <= C_ENDBAL
  179.            AND CU_ZIP  BETWEEN  '11111'  AND  '99999'
  180.            AND CU_NAME LIKE 'B%Vald%'
  181.            AND (CU_SSN = C_SSN1 OR CU_SSN = C_SSN2);
  182.  
  183.  
  184. Record Blocking and ARI
  185.  
  186. The median value is being found for the column C_ENDBAL
  187. from the table CHECKING.  The module noari() uses the SQL
  188. queries:
  189.  
  190.      EXEC SQL SELECT COUNT(*)
  191.          INTO :num_rows
  192.          FROM BMCHUGH.CHECKING;
  193.  
  194.      EXEC SQL DECLARE CBLOCK CURSOR FOR
  195.         SELECT C_ENDBAL FROM BMCHUGH.CHECKING
  196.         ORDER BY C_ENDBAL;
  197.  
  198. Then the cursor CBLOCK is used, num_rows/2 times, to FETCH
  199. the desired median balance.
  200.  
  201.  
  202. /************************************************************************/
  203.                         APPENDIX A
  204. /************************************************************************/
  205.  
  206.             List of source files and functions
  207.  
  208. /************************************************************************/
  209. /* Source File  Modules           Includes   make/def/link   Text Files
  210. /************************************************************************/
  211.   DBDEMO.SQC    main()            DBDEMO.H   DBDEMO          DBDEMO.IPF
  212.                 **PM Functions**  DBCOMM.H   DBDEMO.LNK
  213.                 DDOCMsgProc()     DBDEMODB.H DBDEMO.DEF
  214.                 DOCPARMSsgProc()  DLGDBDEM.H DBDEMO.RC
  215.                 EDITBOXMsgProc()
  216.                 SHOWTIMEMsgProc()
  217.                 WndProc()
  218.                 SetDlgText()
  219.                 PMErrChk()
  220.                 **DB functions**
  221.                 SQLthread()
  222.                 StartDB()
  223.                 StopDB()
  224. /************************************************************************/
  225.   STAT_DYN.SQC  stat_dyn()        DBCOMM.H   DBDEMO        STAT_DYN.TXT
  226.                 stat()            DB.H
  227.                 dyn()
  228. /************************************************************************/
  229.   INDICES.SQC  indices()          DBCOMM.H   DBDEMO        INDICES.TXT
  230.                indx()             DB.H
  231.                noindex()
  232. /************************************************************************/
  233.   RBLOCK.SQC   rblock()           DBCOMM.H   DBDEMO         RBLOCK.TXT
  234.                blocking()         DB.H
  235.  
  236.   RBLOCKNO.SQC rblockno()         DBCOMM.H
  237.                blockin_no()       DB.H
  238. /************************************************************************/
  239.   ARI.SQC      ari()              DBCOMM.H   DBDEMO         ARI.TXT
  240.                arir()             DB.H
  241.  
  242.   ARIS.SQC     get_total()                   ARIS
  243.                                              ARIS.DEF
  244.                                              ARIS.LNK
  245. /************************************************************************/
  246.  GETERR.C      get_error()                   DBDEMO
  247.  DELTA.C       delta()                       DBDEMO
  248. /************************************************************************/
  249.  DBDEMO.DOC     contains this document
  250.  
  251.  The following files contain a list of configuration parameters
  252.  which are displayed by the program:
  253.  
  254.  DBMPARMS.TXT   contains a table of DATABASE MANAGER parameters
  255.  DBPARMSG.TXT   contains a table of DATABASE GENERAL parameters
  256.  DBPARMSH.TXT   contains a table of DATABASE HEAP parameters
  257.  DBPARMSL.TXT   contains a table of DATABASE LOG parameters
  258.  RDSSRV.TXT     contains info on installing RDS on a server
  259.  RDSREQ.TXT     contains info on installing RDS on a requester
  260.  
  261.  
  262. /************************************************************************/
  263.                         APPENDIX B
  264. /************************************************************************/
  265. TABLE=BMCHUGH.CHECKING
  266.  
  267. Column Name         Type                   Length  Attributes
  268. -----------         ----                   ------  ----------
  269. C_ACCNUMB           Character (Fixed)      8       Data required, Text
  270. C_STARTBAL          Decimal                9,2     Data required
  271. C_ENDBAL            Decimal                9,2     Data required
  272. C_SSN1              Character (Fixed)      11      Data required, Text
  273. C_SSN2              Character (Fixed)      11      Text
  274.  
  275.  
  276. TABLE=BMCHUGH.CUSTOMER
  277.  
  278. Column Name         Type                   Length  Attributes
  279. -----------         ----                   ------  ----------
  280. CU_SSN              Character (Fixed)      11      Data required, Text
  281. CU_NAME             Character (Fixed)      30      Data required, Text
  282. CU_ADDR1            Character (Fixed)      25      Data required, Text
  283. CU_ADDR2            Character (Fixed)      25      Data required, Text
  284. CU_ZIP              Character (Fixed)      5       Data required, Text
  285.  
  286.  
  287. TABLE=BMCHUGH.SAVINGS
  288.  
  289. Column Name         Type                   Length  Attributes
  290. -----------         ----                   ------  ----------
  291. S_ACCNUMB           Character (Fixed)      8       Data required, Text
  292. S_IRATE             Decimal                5,2     Data required
  293. S_INTTOD            Decimal                7,2
  294. S_BAL               Decimal                9,2     Data required
  295. S_SSN               Character (Fixed)      11      Data required, Text
  296.  
  297.  
  298. TABLE=BMCHUGH.PERFDAT3
  299.  
  300. Column Name         Type                   Length  Attributes
  301. -----------         ----                   ------  ----------
  302. CU_SSN              Character (Fixed)      11      Data required, Text
  303. CU_NAME             Character (Fixed)      30      Data required, Text
  304. CU_ADDR1            Character (Fixed)      25      Data required, Text
  305. CU_ADDR2            Character (Fixed)      25      Data required, Text
  306. CU_ZIP              Character (Fixed)      5       Data required, Text
  307. L_NUMB              Character (Fixed)      8       Data required, Text
  308. L_TYPE              Character (Fixed)      1       Data required, Text
  309. L_RATE              Decimal                5,2     Data required
  310. L_TERM              Small Integer                  Data required
  311. L_PAYMT             Decimal                7,2     Data required
  312. L_BAL               Decimal                9,2     Data required
  313. L_INTODAT           Decimal                9,2
  314. L_DESCRIP           Character (Fixed)      25      Data required, Text
  315. L_DATE              Date
  316. S_ACCNUMB           Character (Fixed)      8       Data required, Text
  317. S_IRATE             Decimal                5,2     Data required
  318. S_INTTOD            Decimal                7,2
  319. S_BAL               Decimal                9,2     Data required
  320. B_NUMB              Character (Fixed)      3       Data required, Text
  321. B_SIZE              Character (Fixed)      1       Data required, Text
  322. B_RENT              Decimal                3,2     Data required
  323. B_PAYUP             Character (Fixed)      3       Text
  324. C_ACCNUMB           Character (Fixed)      8       Data required, Text
  325. C_STARTBAL          Decimal                9,2     Data required
  326. C_ENDBAL            Decimal                9,2     Data required
  327.  
  328. ******INDEXES******
  329.  
  330. Index Name:     BMCHUGH.XCU_SSN
  331.  
  332. Duplicates Allowed:        Yes
  333.  
  334. Column Name         Order
  335. -----------         -----
  336. CU_SSN              Ascending
  337.  
  338.  
  339. References Articles and Performance Documemtation:
  340.  
  341.  
  342. 1. OS/2 EE Database Manager Administrator's Guide, Chapter 7, (S01F-0267).
  343.  
  344. 2. ITSC's OS/2 EE 1.2 Database Services and Query Manager, Cookbook, (GG24-3557).
  345.  
  346. 3. OS/2 EE 1.2 Database Manager Performance, Velasco and Li, IBM Personal
  347.         System Developer, issue 1, 1991.
  348.  
  349. 4. Inside IBM's Database Strategy, DBMS supplement.
  350.  
  351. 5. Software Digest Buyer's Alert, vol 7, num. 13, 1990.
  352.  
  353. 6. "Database Application Design Class", IBM video-tapes, Tim Li, Dan Hargrove,
  354.         Tim Malkemus, Feb 22 and 23, 1990.
  355.  
  356. 7. Configuring Os/2 1.1 Database Services, IBM FTN video-tapes, May 11, 1989.
  357.  
  358. 8. OS/2 EE Database Manager: Configuration Parameters, Baker et al, IBM
  359.         Personal Systems Developer, Spring 1990.
  360.  
  361. 9. The Database Manager Optimizer, pp 74, IBM Personal System Developer,
  362.         Summer, 1989.
  363.  
  364. 10. Performance of OS/2 EE 1.1 Database Services, Velasco and Li, IBM
  365.         Personal System Developer, Summer, 1989.
  366.  
  367. 11. OS/2 Notebook Best Of Personal System Developer.
  368.  
  369. 12. Client-Server Programming With OS/2 Extended Edition.
  370.     Robert Orfali and Dan Harkey
  371.  
  372. 13. DataBase Application Remote Interface.
  373.     Lance Amundsen and Nameeta Sappal
  374.  
  375. 14. COOKBOOKS
  376.      A. Database Remote Data Services
  377.      B. Communication Manager and Database Introduction
  378.      C. Database Manager and Database Services and Query Manager
  379.      D. Database Manager - User Profile Manager
  380.      E. Performance and Capacity Optimization
  381.      F. Print Subsystems
  382.  
  383. 15. CUA Documentation
  384.      Advanced Interface Design Guide
  385.  
  386. 16. CPI Documentation
  387.      Database Reference
  388.  
  389.