file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/178-183.html (3 of 6)4/03/2005 6:15:43
Display Image on Left Partition
Figure 7.3 depicts the Web page using htp.div.
Figure 7.3 A sample Web page using htp.div.
htp.dlistClose The htp.dlistClose hypertext procedure ends a list of definitions. These definitions are listed in an indented format. There are no parameters for this procedure.
Note: See procedure htp.dlistDef for examples of the PL/SQL and HTML code related to this procedure.
htp.dlistDef The htp.dlistDef procedure creates an HTML tag to build a list of definitions. Terms can be inserted within this list using the htp.dlistTerm procedure. Notice in the Web page displayed in Figure 7.4 that the terms appear in an indented format within the definition list.
Figure 7.4 A sample Web page using htp.dlistDef.
Note: To insert the terms within the definition list, the htp.dlistTerm procedure call must follow the htp.dlistDef procedure call.
Parameters: ctext(in), cclear(in), cattributes(in) • ctext—Identifies the definition list (varchar2). Default NULL. • cclear—Setting for inserting a new line into the document (varchar2). Default NULL. • cattributes—Settings for common HTML tags (varchar2). Default NULL. Listing 7.7 displays a PL/SQL code example using the htp.dlistDef procedure, and Listing 7.8
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/178-183.html (4 of 6)4/03/2005 6:15:43
Oracle Databases on the Web:WebServer's HTP Utilities
shows the HTML code generated by this procedure. Listing 7.7 PL/SQL code using htp.dlistDef. create or replace procedure dlistprc as begin htp.htmlOpen; htp.headOpen; htp.header(1,'Oracle WebServer htp.dlistDef Example'); htp.headClose; htp.bodyOpen; htp.dlistOpen; htp.dlistDef('Definition List 1'); htp.dlistTerm('Definition Term 1'); htp.dlistTerm('Definition Term 2'); htp.dlistTerm('Definition Term 3'); htp.dlistTerm('Definition Term 4'); htp.dlistTerm('Definition Term 5'); htp.dlistClose; htp.bodyClose; htp.htmlClose; end; / show errors Listing 7.8 HTML code using htp.dlistDef.
Oracle WebServer htp.dlistDef Example
- Definition List 1
- Definition Term 1
- Definition Term 2
- Definition Term 3
- Definition Term 4
- Definition Term 5
Figure 7.4 depicts a Web page using htp.dlistDef.
Previous Table of Contents Next
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/178-183.html (5 of 6)4/03/2005 6:15:43
Oracle Databases on the Web:WebServer's HTP Utilities
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/178-183.html (6 of 6)4/03/2005 6:15:43
Oracle Databases on the Web:WebServer's HTP Utilities
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
htp.dlistOpen The htp.dlistOpen hypertext procedure creates an HTML tag to open an indented list of definitions in a definition list. Parameters: cclear(in), cattributes(in) • cclear—Determines if a new line is inserted into the document (varchar2). Default NULL. • cattributes—Settings for common HTML tags (varchar2). Default NULL.
Note: See procedure htp.dlistDef for examples of the PL/SQL and HTML code related to this procedure.
htp.dlistTerm The htp.dlistTerm hypertext procedure generates an HTML tag to list terms within a definition list. The terms are listed in an indented format, following the definition list name. The htp.dlistTerm procedure call must immediately follow the call to the htp. dlistDef procedure. Parameters: ctext(in), cclear(in), cattributes(in) file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/184-186.html (1 of 3)4/03/2005 6:15:43
Oracle Databases on the Web:WebServer's HTP Utilities
• ctext—Identifies the definition terms (varchar2). Default NULL. • cclear—Determines if a new line is inserted into the document (varchar2). Default NULL. • cattributes—Settings for common HTML tags (varchar2). Default NULL.
Note: See procedure htp.dlistDef for examples of the PL/SQL and HTML code related to this procedure.
htp.em The htp.em hypertext procedure is the alias for the procedure htp.emphasis. This alias will highlight the specified text.
htp.emphasis The htp.emphasis hypertext procedure highlights text specified as input. The type of highlighting employed may vary, but in most instances, the text appears italicized. Parameters: ctext(in), cattributes(in) • ctext—Identifies the text to be emphasized (varchar2). • cattributes—Attribute settings for HTML tags (varchar2). Default NULL.
htp.fontClose The htp.fontClose hypertext procedure ends a section of text using special, definedfont settings. There are no parameters necessary for this procedure.
htp.fontOpen The htp.fontOpen hypertext procedure begins a section of text using special, definedfont settings. This is helpful for making portions of the text stand out. Parameters: ccolos(in), cface(in), csize(in), cattributes(in) • ccolor—Defines a color setting for the text (varchar2). Default NULL. • cface—Defines how the typeface will be characterized (varchar2). Default NULL. • csize—Defines the size characteristic for the text (varchar2). Default NULL. • cattributes—Attribute settings for the HTML tags (varchar2). Default NULL.
htp.formCheckbox The htp.formCheckbox hypertext procedure inserts checkboxes, which can be clicked on and off.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/184-186.html (2 of 3)4/03/2005 6:15:43
Oracle Databases on the Web:WebServer's HTP Utilities
Parameters: cname(in), cvalue(in), cchecked(in), cattributes(in) • cname—Defines the internal reference name for the contents of the field (varchar2). The name for each checkbox button should be different because you can make multiple selections. • cvalue—Indicates the value for the checkbox button (varchar2). Default ON. Each checkbox button should have the same value indicating that it was selected. The name of the button should provide distinguishing information for that button. • cchecked—Defines a button as checked (varchar2). Default NULL. • cattributes—Attribute settings for HTML tags (varchar2). Default NULL. Listing 7.9 displays a PL/SQL code example using the htp.formCheckbox procedure, and Listing 7.10 shows the HTML code generated by this procedure.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/184-186.html (3 of 3)4/03/2005 6:15:43
Oracle Databases on the Web:WebServer's HTP Utilities
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Listing 7.9 PL/SQL code using htp.formCheckbox. create or replace procedure formcheckbox (tab_name in varchar2) is cursor cols is select column_name from dba_tab_columns where table_name = upper(tab_name); BEGIN htp.htmlOpen; htp.headOpen; htp.htitle('Query the '||tab_name||' table by checking columns below.'); htp.headClose; htp.bodyOpen; htp.formOpen(owa_util.get_owa_service_path||'do_query'); htp.formHidden('tab_name', tab_name); htp.formHidden('COLS', 'dummy'); for crec in cols loop htp.formCheckbox('COLS',crec.column_name); htp.print(crec.column_name); htp.nl; end loop;
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/186-191.html (1 of 5)4/03/2005 6:15:44
Oracle Databases on the Web:WebServer's HTP Utilities
htp.formSubmit(NULL, 'Execute Query'); htp.formClose; htp.bodyClose; htp.htmlClose; end; / show errors Listing 7.10 HTML code using htp.formCheckbox. <TITLE>Query the dba_tables table by checking columns below.
Query the dba_tables table by checking columns below.
Figure 7.5 depicts the Web page using htp.formCheckbox.
Figure 7.5 A sample Web page using htp.formCheckbox.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/186-191.html (3 of 5)4/03/2005 6:15:44
Oracle Databases on the Web:WebServer's HTP Utilities
htp.formClose The htp.formClose hypertext procedure closes an HTML form. Forms are opened by the htp. formOpen procedure. There are no parameters for this procedure.
Note: See procedure htp.formSelectOpen for examples of the PL/SQL and HTML code related to this procedure.
htp.formHidden The htp.formHidden hypertext procedure sends a field value with a form. However, the user will not see the value as part of the transmission. Parameters: cname(in), cvalue(in), cattributes(in) • cname—Defines the internal reference name for the contents of the field (varchar2). • cvalue—Assigns the value of the field (varchar2). Default NULL. • cattributes—Attribute settings for HTML tags (varchar2). Default NULL.
Note: See procedure htp.formCheckbox for examples of the PL/SQL and HTML code related to this procedure.
htp.formImage The htp.formImage hypertext procedure posts an image that can be clicked on to submit a form. Parameters: cname(in), csrc(in), calign(in), cattributes(in) • • • •
cname—Creates an internal reference name for the image (varchar2). csrc—Indicates the actual image file name (varchar2). calign—Defines the placement for the image on the Web page (varchar2). Default NULL. cattributes—Attribute settings for HTML tags (varchar2). Default NULL.
Creating an image map is accomplished by using a combination of the formImage and formOpen hypertext procedures. As you can see in Listing 7.11, the formImage procedure parameters include the internal name of the image (BobPic), and the actual image file (papaj.gif, which, in this case, happens to be me). Now, you also need the formOpen procedure to tell the Web Listener where you are transferring to based on where you clicked on the image. The hotspots on the image are defined by X and Y coordinates. This cumbersome task of defining hotspots on image maps was discussed in the CGI chapter. When you click on a specific X,Y coordinate on an image, three parameters are passed to the URL identified in the formOpen procedure. The URL in Listing 7.11 is the procedure called ‘s00’, which must be set up to receive the three parameters, including the internal image name, the X coordinate, and the Y coordinate. So, if you click on Bob’s nose, you go to one URL, and if you click on Bob’s ear, you go to another location. For another perspective on the relationship between the formOpen and formImage procedures, see the htp.formOpen definition.
Previous Table of Contents Next
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/186-191.html (4 of 5)4/03/2005 6:15:44
Oracle Databases on the Web:WebServer's HTP Utilities
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/186-191.html (5 of 5)4/03/2005 6:15:44
Oracle Databases on the Web:WebServer's HTP Utilities
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Listing 7.11 displays a PL/SQL code example using the htp.formImage procedure, and Listing 7.12 shows the HTML code generated by this procedure. Listing 7.11 PL/SQL code using htp.formImage. create or replace procedure formimage as begin htp.htmlOpen; htp.headOpen; htp.title('Oracle Webserver formImage'); htp.header(1,'Oracle WebServer htp.formImage Examples'); htp.headClose; htp.bodyOpen; htp.formOpen(owa_util.get_owa_service_path || 's00'); htp.print('Click on the Image to submit Form'); htp.formImage('BobPic','/ows-img/papaj.gif'); htp.nl; htp.formClose; htp.bodyClose; htp.htmlClose; end; / show errors Listing 7.12 HTML code using htp.formImage. <TITLE>Oracle Webserver formImage
Oracle WebServer htp.formImage Examples
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/191-195.html (1 of 4)4/03/2005 6:15:45
Oracle Databases on the Web:WebServer's HTP Utilities
Figure 7.6 depicts the Web page using htp.formImage.
Figure 7.6 A sample Web page using htp.formImage.
htp.formOpen The htp.formOpen hypertext procedure specifies the name of the procedure that will be invoked when a form is submitted. Generally, a form is submitted using htp.formSubmit or htp.formImage. The formOpen is always used in combination with either formSubmit or formImage. Parameters: curl(in), cmethod(in), ctarget(in), cenctype(in), cattributes(in) • curl—This is the URL identifying the executable script (e.g., CGI) that will generate the form (varchar2). • cmethod—This is the method used to transfer data to and from the form (varchar2). Default POST. The other option is GET. • ctarget—This parameter should be left blank (varchar2). • cenctype—This is the encryption type for the data being transferred (varchar2). Default NULL. • cattributes—Attribute settings for HTML tags (varchar2). Default NULL. For example, this pair will create a push button, which, when clicked, will create the Web page defined in the stored procedure called destination_page_name : htp.formOpen(owa_util_.get_owa_service_path||'destination_page_name'); htp.formSubmit(NULL, 'Press here to transfer to destination Web page');
Note: Normally a stored procedure name is used with htp.formSubmit, but here NULL is used, so the stored procedure specified by htp.formOpen is used.
In this example, a form image will be created which, when clicked, will create the Web page that is defined in the stored procedure called destination_page_name : htp.formOpen(owa_util_.get_owa_service_path||'destination_page_name'); htp.formImage('internal_image_name','actual_image_file_name'); htp.formImage will pass three parameters to destination_procedure_name. It will pass internal_image_name internal_image_name.x internal_image_name.y
varchar2; int; int;
where x is the X pixel coordinate and y is the Y pixel coordinate. These coordinates are used by the
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/191-195.html (2 of 4)4/03/2005 6:15:45
Oracle Databases on the Web:WebServer's HTP Utilities
receiving page to interrogate the pixel coordinates and transfer to other functions. Therefore, in this case, destination_procedure_name would need to be defined with these three input parameters. Here is the prototype: destination_procedure_name(internal_image_in in varchar2, internal_image_in.x in int, internal_image_in.y in int);
htp.formPassword The htp.formPassword hypertext procedure creates a protected data entry field. Parameters: cname(in), csize(in), cmaxlength(in), cvalue(in), cattributes(in) • cname—Defines the internal reference name for the contents of the field (varchar2). • csize—Defines the displayed number of characters (varchar2). • cmaxlength—Defines the maximum number of characters that the field can contain (varchar2). Default NULL. • cvalue—Defines the value associated with the password (varchar2). Default NULL. • cattributes—Attribute settings for HTML tags (varchar2). Default NULL.
Note: A text field with csize=5 and cmaxlength=10 will only display 5 characters, but it will be able to accept 10 characters. In this case, you may enter 10 characters, and use the arrow keys to display the entire text string.
Listing 7.13 displays a PL/SQL code example using the htp.form Password procedure, and Listing 7.14 shows the HTML code generated by this procedure. Listing 7.13 PL/SQL code using htp.formPassword. create or replace procedure formpassword as begin htp.htmlOpen; htp.headOpen; htp.title('Oracle Webserver formPassword'); htp.header(1,'Oracle WebServer htp.formPassword Examples'); htp.headClose; htp.bodyOpen; htp.formOpen(owa_util.get_owa_service_path || 'formpassword'); htp.print('ENTER Userid: '); htp.formText('Userid',10,50); htp.nl; htp.print('ENTER Password: '); htp.formPassword('Password',10,50); htp.nl; htp.formClose; htp.bodyClose; htp.htmlClose; end; / show errors Listing 7.14 HTML code using htp.formPassword. file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/191-195.html (3 of 4)4/03/2005 6:15:45
Oracle Databases on the Web:WebServer's HTP Utilities
<TITLE>Oracle Webserver formPassword
Oracle WebServer htp.formPassword Examples
Figure 7.7 depicts the Web page using htp.formPassword.
Figure 7.7 A sample Web page using htp.formPassword.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/191-195.html (4 of 4)4/03/2005 6:15:45
Oracle Databases on the Web:WebServer's HTP Utilities
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
htp.formRadio The htp.formRadio hypertext procedure inserts a radio button into an HTML form. Parameters: cname(in), cvalue(in), cchecked(in), cattributes(in) • cname—Defines the internal reference name for the contents of the field (varchar2). Each radio button should have the same name because you can only select one. • cvalue—Assigns the value associated with this button (varchar2). For example, one radio button might have the value “Visa” and another “Amex”. • cchecked—Indicates that the button default is “checked” (varchar2). Default NULL. • cattributes—Attribute settings for HTML tags (varchar2). Default NULL. Listing 7.15 displays a PL/SQL code example using the htp.formRadio procedure, and Listing 7.16 shows the HTML code generated by this procedure. Listing 7.15 PL/SQL code using htp.formRadio. create or replace procedure formradio is cursor cols is select nationality from nations order by nationality ; BEGIN
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/195-200.html (1 of 5)4/03/2005 6:15:46
Oracle Databases on the Web:WebServer's HTP Utilities
htp.htmlOpen; htp.headOpen; htp.htitle('Choose a nationality.'); htp.headClose; htp.bodyOpen; htp.formOpen(owa_util.get_owa_service_path||'formradio'); htp.formHidden('COLS', 'dummy'); for crec in cols loop htp.formRadio('COLS',crec.nationality); htp.print(crec.nationality); htp.nl; end loop; htp.formSubmit(NULL, 'Execute Query'); htp.formClose; htp.bodyClose; htp.htmlClose; end; / show errors Listing 7.16 HTML code using htp.formRadio. <TITLE>Choose a nationality.
Choose a nationality.
Figure 7.8 depicts the Web page using htp.formRadio.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/195-200.html (2 of 5)4/03/2005 6:15:46
Oracle Databases on the Web:WebServer's HTP Utilities
Figure 7.8 A sample Web page using htp.formRadio.
htp.formReset The htp.formReset hypertext procedure inserts a Reset button into an HTML form, which can be used to reset all the input data fields to their original values. Parameters: cvalue(in), cattributes(in) • cvalue—Defines the value associated with the button (varchar2). Defaults to Reset. • cattributes—Settings to define the HTML tag attributes (varchar2). Default NULL. Listing 7.17 displays a PL/SQL code example using the htp.formReset procedure, and Listing 7.18 shows the HTML code generated by this procedure. Listing 7.17 PL/SQL code using htp.formReset. create or replace procedure formreset as begin htp.htmlOpen; htp.headOpen; htp.title('Oracle Webserver formReset'); htp.header(1,'Oracle WebServer htp.formReset Examples'); htp.headClose; htp.bodyOpen; htp.formOpen(owa_util.get_owa_service_path || 'formreset'); htp.print('Server Name: '); htp.formText('Server Name',10,50); htp.nl; htp.print('Instance Name: '); htp.formText('Instance Name',10,50); htp.nl; htp.formReset; htp.nl; htp.formClose; htp.bodyClose; htp.htmlClose; end; / show errors Listing 7.18 HTML code using htp.formReset. <TITLE>Oracle Webserver formReset file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/195-200.html (3 of 5)4/03/2005 6:15:46
Oracle Databases on the Web:WebServer's HTP Utilities
Oracle WebServer htp.formReset Examples
Figure 7.9 depicts the Web page using htp.formReset.
Figure 7.9 A sample Web page using htp.formReset.
htp.formSelectClose The htp.formSelectClose hypertext procedure ends a list of selections. This HTML section is opened by the htp.formSelectOpen procedure. There are no parameters for this procedure.
Note: See procedure htp.formSelectOpen for examples of the PL/SQL and HTML code related to this procedure.
htp.formSelectOpen The htp.formSelectOpen hypertext procedure begins a list of alternatives to select. Parameters: cname(in), cprompt(in), nsize(in), cattributes(in) • cname—Defines the internal reference name for the selection (varchar2). • cprompt—Creates a text prompt on the form for the selections(varchar2). Default NULL. • nsize—Determines the number of selections on the form (integer). Default NULL. • cattributes—Attribute settings for HTML tags (varchar2). Default NULL. Listing 7.19 displays a PL/SQL code example using the htp.formSelectOpen procedure, and Listing 7.20 shows the HTML code generated by this procedure. Listing 7.19 PL/SQL code using htp.formSelectOpen. create or replace procedure formselectopen as begin htp.htmlOpen; htp.headOpen; htp.title('Oracle Webserver formSelectOpen'); file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/195-200.html (4 of 5)4/03/2005 6:15:46
Oracle Databases on the Web:WebServer's HTP Utilities
htp.header(1,'Oracle WebServer htp.formSelectOpen Examples'); htp.headClose; htp.bodyOpen; htp.formOpen(owa_util.get_owa_service_path || 'test'); htp.formSelectOpen('input_var_name:','Choose the Server Site:'); htp.nl; htp.nl; htp.formSelectOption('Buffalo'); htp.nl; htp.formSelectOption('Rochester'); htp.nl; htp.formSelectOption('Syracuse'); htp.nl; htp.formSelectClose; htp.formClose; htp.bodyClose; htp.htmlClose; end; / show errors
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/195-200.html (5 of 5)4/03/2005 6:15:46
Oracle Databases on the Web:WebServer's HTP Utilities
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Listing 7.20 HTML code using htp.formSelectOpen. <TITLE>Oracle Webserver formSelectOpen
Oracle WebServer htp.formSelectOpen Examples
Figure 7.10 depicts the Web page using htp.formSelectOpen.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/201-205.html (1 of 5)4/03/2005 6:15:46
Oracle Databases on the Web:WebServer's HTP Utilities
Figure 7.10 A sample Web page using htp.formSelectOpen.
Note: Rather than hard-coding the pop-up values in the form, you can retrieve the values from your Oracle database and dynamically create a Web page with the database values. To see how to dynamically generate pop-up lists, see Chapter 10.
htp.formSelectOption The htp.formSelectOption hypertext procedure represents one selection from a list. This list is displayed within the context of an HTML form. Parameters: cvalue(in), cselected(in), cattributes(in) • cvalue—Defines the displayed selection (varchar2). • cselected—Does nothing. Default NULL. • cattributes—Settings for the attributes of HTML tags (varchar2). Default NULL.
Note: See procedure htp.formSelectOpen for examples of the PL/SQL and HTML code related to this procedure.
htp.formSubmit The htp.formSubmit hypertext procedure creates a button used to submit a form. Parameters: cname(in), cvalue(in), cattributes(in) • cname—Defines the internal reference name for the form (varchar2). Default NULL. • cvalue—Identifies the button as one being used for submitting forms (varchar2). Default Submit. • cattributes—Settings for the attributes of HTML tags (varchar2). Default NULL.
Note: See procedure htp.formRadio for examples of the PL/SQL and HTML code related to this procedure.
htp.formText The htp.formText function creates an input field for textual data entry and updates. Parameters: cname(in), csize(in), cmaxlength(in), cvalue(in), cattributes(in) file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/201-205.html (2 of 5)4/03/2005 6:15:46
Oracle Databases on the Web:WebServer's HTP Utilities
• cname—Defines the internal reference name for the contents of the field (varchar2). • csize—Assigns the displayed number of characters in the field (varchar2). Default NULL. • cmaxlength—Defines the maximum number of characters that the field can contain (varchar2). Default NULL. • cvalue—Indicates the default text within the field (varchar2). Default NULL. • cattributes—Settings for the attributes of HTML tags (varchar2). Default NULL.
Note: A text field with csize=5 and cmaxlength=10 will only display 5 characters, but will be able to accept 10 characters. In this case, you may enter 10 characters, and use the arrow keys to display the entire text string.
Listing 7.21 displays a PL/SQL code example using the htp.formText procedure, and Listing 7.22 shows the HTML code generated by this procedure. Listing 7.21 PL/SQL code using htp.formText. create or replace procedure formtext as begin htp.htmlOpen; htp.headOpen; htp.title('Oracle Webserver formText'); htp.header(1,'Oracle WebServer htp.formText Examples'); htp.headClose; htp.bodyOpen; htp.formOpen(owa_util.get_owa_service_path || 'formtext'); htp.print('Size 1: '); htp.formText('U',10,50); htp.nl; htp.print('Size 10: '); htp.formText('V',10,50); htp.nl; htp.print('Size 20: '); htp.formText('W',20,50); htp.nl; htp.print('Size 30: '); htp.formText('X',30,50); htp.nl; htp.print('Size 40: '); htp.formText('Y',40,50,'This is a default value'); htp.nl;
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/201-205.html (3 of 5)4/03/2005 6:15:46
Oracle Databases on the Web:WebServer's HTP Utilities
htp.formClose; htp.bodyClose; htp.htmlClose; end; / show errors Listing 7.22 HTML code using htp.formText. <TITLE>Oracle Webserver formText
Oracle WebServer htp.formText Examples
Figure 7.11 depicts the Web page using htp.formText.
Figure 7.11 A sample Web page using htp.formText.
htp.formTextarea The htp.formTextarea hypertext procedure creates a text area that does not have any predefined text. This procedure enables a user to enter text into the text field. Parameters: cname(in), nrows(in), ncols(in), calign(in), cattributes(in)
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/201-205.html (4 of 5)4/03/2005 6:15:46
Oracle Databases on the Web:WebServer's HTP Utilities
• • • • •
cname—Names the text field (varchar2). nrows—Defines the number of rows in the text field (integer). ncols—Defines the number of text columns (integer). calign—Sets the text input alignment (varchar2). Default NULL. cattributes—Attribute settings for HTML tags (varchar2). Default NULL.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/201-205.html (5 of 5)4/03/2005 6:15:46
Oracle Databases on the Web:WebServer's HTP Utilities
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
FAQ/ site help map
search
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
htp.formTextarea2 The htp.formTextarea2 hypertext procedure creates a text area that does not have any predefined text and allows text to be entered by a user into the text field. However, this procedure is different from htp.formTextarea in that it allows for a wrap style for the text. Parameters: cname(in), nrows(in), ncols(in), calign(in), cwrap(in), cattributes(in) • • • • • •
cname—Names the text field (varchar2). nrows—Defines the number of rows in the text field (integer). ncols—Defines the number of text columns (integer). calign—Sets the text input alignment (varchar2). Default NULL. cwrap—Specifies a text wrap style (varchar2). Default NULL. cattributes—Attribute settings for HTML tags (varchar2). Default NULL.
htp.formTextareaClose The htp.formTextareaClose hypertext procedure ends a text area field defined with procedure htp.formTextarea. There are no parameters necessary for this procedure.
htp.formTextareaClose2 The htp.formTextareaClose2 hypertext procedure ends a text area field defined with file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/205-208.html (1 of 3)4/03/2005 6:15:47
Oracle Databases on the Web:WebServer's HTP Utilities
procedure htp.formTextarea2. There are no parameters associated with this procedure.
htp.formTextareaOpen The htp.formTextareaOpen hypertext procedure begins a text area (section defined for text). Within this text area, predefined text can be inserted. Parameters: cname(in), nrows(in), ncols(in), calign(in), cattributes(in) • • • • •
cname—Names the text area (varchar2). nrows—Defines the number of rows in the text area (integer). ncols—Defines the number of text columns (integer). calign—Sets the text input alignment (varchar2). Default NULL. cattributes—Attribute settings for HTML tags (varchar2). Default NULL.
formTextareaOpen2 The formTextareaOpen2 hypertext procedure begins a text area with predefined text. The predefined text will always be displayed in the text field. This procedure allows for the specification of a wrap style for the text. Parameters: cname(in), nrows(in), ncols(in), calign(in), cwrap(in), cattributes(in) • • • • • •
cname—Names the text area (varchar2). nrows—Defines the number of rows in the text area (integer). ncols—Defines the number of text columns (integer). calign—Sets the text input alignment (varchar2). Default NULL. cwrap—Sets the text wrapping style (varchar2). Default NULL. cattributes—Attribute settings for HTML tags (varchar2). Default NULL.
htp.frame The htp.frame hypertext procedure generates an HTML tag that defines a frame. A frame is a way of separating data or functions into different windows within a Web page, thus enabling distinct processing to occur within partitioned sections of the document. Parameters: csrc(in), cname(in), cmarginwidth(in), cmarginheight(in), cscrolling(in), cnoresize(in), cattributes(in) • csrc—Names the object to be sourced within the frame (varchar2). • cname—Defines the internal name of the frame (varchar2). Default NULL. • cmarginwidth—Defines the width of the frame (varchar2). Default NULL. • cmarginheight—Defines the height of the frame (varchar2). Default NULL. • cscrolling—Defines scrolling for the frame (varchar2). Default NULL. • cnoresize—Defines no-resizing for this frame (varchar2). Default NULL. • cattributes—Settings for the HTML tag attributes (varchar2). Default NULL.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch07/205-208.html (2 of 3)4/03/2005 6:15:47
Oracle Databases on the Web:WebServer's HTP Utilities
htp.framesetClose The htp.framesetClose hypertext procedure generates an HTML tag to end a group of frames within a Web page. This group of frames was opened by the htp. framesetOpen procedure. There are no parameters related to this hypertext procedure.
htp.framesetOpen The htp.framesetOpen hypertext procedure begins a set of frames within a Web page. There are no required parameters associated with this procedure. Parameters: crows(in), ccols(in), cattributes(in) • crows—Defines the number of rows for the frame (varchar2). Default NULL. • ccols—Defines the number of columns for the frame (varchar2). Default NULL. • cattributes—Settings for the HTML tag attributes (varchar2). Default NULL.
htp.headClose The htp.headClose hypertext procedure specifies the end of the head in the HTML document. There are no parameters associated with this procedure. The HTML head is opened by hypertext procedure htp.headOpen.
Previous Table of Contents Next The commands and their arguments are explained as follows: • config—This command defines how the LiveHTML code will be parsed. The arguments related to this command include: • errmsg—This argument allows for the specification of an error message encountered during parsing. • sizefmt—When displaying a file size, this argument will determine the format that will be used. The options include abbrev, which presents the size in kilobytes or megabytes, and bytes, which obviously presents the size in bytes. • timefmt—If any dates are displayed on a LiveHTML document, this argument defines their formatting, based on the strftime library calls of Unix. • cmdech—Passing the value ON through this argument will include output from a non-CGI script into an HTML page. Passing the value OFF (which is the default) will not incorporate the output into the document. • cmdprefix—This argument passes text that is attached to the front of
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch12/419-423.html (1 of 3)4/03/2005 6:16:26
Oracle Databases on the Web:Using Java And LiveHTML With Oracle WebServer
all lines of output. • cmdpostfix—The text passed through this argument is attached to the end of every output line. • include—This command allows for a file containing information to be embedded into a Web page. These files can be of different varieties, including normal HTML files, other LiveHTML files, and ASCII files. The arguments related to this command include: • file—This argument specifies the directory name for the file location, relative to the current directory. • virtual—The virtual directory location of the file to be sourced can be specified with this argument. The mapping of virtual directories within Oracle WebServer is accomplished through the WebServer Manager, as discussed in detail in Chapter 4, Installing And Configuring Oracle WebServer. • echo—This command returns the contents of any environmental variables that may be LiveHTML extensions (Server Side Include variables) or CGI environmental variables. From previous chapters, you know that CGI variables are passed between Oracle WebServer and the browser through environmental variables, regardless of whether the gateway interface used is the CGI or Web Request Broker. The argument related to this command is: • 22 var—This argument is required for the echo command and may contain one of the following LiveHTML variables: • Last_Modified—The date (formatted by the config timefmt command) that the file was last updated. • Document_Name—The name of the file currently in process. • Document_URL—The location of the file to be sourced, as specified through a virtual directory. • Date_GMT—The current date and local time zone in Greenwich mean time. GMT is the default time zone for the processing of cookies by Oracle WebServer and can be adjusted within the WebServer applications through the owa_init package discussed in Chapter 8, WebServer’s OWA Utilities. • Date_Local—The current date and local time zone, defined by the most recent config timefmt command. • Query_String_Unescaped—This environment variable contains the string sent by a client in unescaped format, but with special characters escaped with a ‘\’ (backslash). • fsize—This command produces the file size as indicated by the last processed config sizefmt command. The same arguments apply as for the include command. • flastmod—This command produces the date that the file was last updated as formatted by the config timefmt command most recently processed. The arguments for this command are the same as those for the include command. • exec—This command executes a script on the server file system, which may or may not be a CGI script. The arguments related to this command include: • cmd—This argument enables the execution of a non-CGI script on the server by specifying the full directory-path location of the script and possibly using the variables specified by the echo command. The config cmdecho command most recently processed determines whether the output from the non-CGI script will be posted to the Web page. • cgi—This argument enables the specification of the virtual directory
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch12/419-423.html (2 of 3)4/03/2005 6:16:26
Oracle Databases on the Web:Using Java And LiveHTML With Oracle WebServer
for a CGI script to be processed on the server. CGI scripts are widely used throughout the Web, but product extensions within Oracle WebServer like LiveHTML are replacing the previously standard processes with improved functionality.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch12/419-423.html (3 of 3)4/03/2005 6:16:26
Oracle Databases on the Web:Using Java And LiveHTML With Oracle WebServer
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Examples Of LiveHTML In order to appreciate the power of LiveHTML, let’s take a look at an Oracle application that actually uses LiveHTML. In our example, we start by displaying a Web page that can be used to interrogate Unix environmental information. (See Figure 12.6). Here, we see that the Web page displays a series of hypertext links to perform different functions on the host server. This would be a very common application of LiveHTML because the goal of this application is to issue a Unix host command, capture the output of the command in a Unix flat file, and then display the contents of the flat file on the Web page.
Figure 12.6 A sample Web page using LiveHTML. file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch12/423-430.html (1 of 7)4/03/2005 6:16:26
Oracle Databases on the Web:Using Java And LiveHTML With Oracle WebServer
As you can see in Figure 12.6, the Web page allows an Oracle developer to access information about specific characteristics of the Unix server. The Oracle developer can press any of the hypertext links to invoke the LiveHTML embedded in the hypertext links. Listing 12.22 shows the Oracle stored procedure code that generated the Web page in Figure 12.6. Listing 12.22 The Oracle stored procedure for the Unix environment query Web page. create or replace procedure s99 as host_name_in varchar2(20); cursor c1 is select host_name from host order by host_name; host_rec c1%ROWTYPE; BEGIN htp.htmlOpen; htp.headOpen; htp.title('s00'); htp.preOpen; htp.header(1,' htp.header(1,' htp.headClose; htp.preClose;
Oracle Information Database'); Online Oracle Report Menu','C');
htp.bodyOpen; htp.formOpen(owa_util.get_owa_service_path || 's99'); htp.FormHidden('host_name_in', host_name_in); file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch12/423-430.html (2 of 7)4/03/2005 6:16:26
Oracle Databases on the Web:Using Java And LiveHTML With Oracle WebServer
htp.FormSelectOpen('host_name_in','Choose the Host:'); open c1; loop fetch c1 into host_rec; EXIT WHEN c1%NOTFOUND; htp.formSelectOption(host_rec.host_name); end loop; close c1; htp.formSelectClose; htp.header(2,'Unix Environmental Reports','C'); htp.anchor('http://hostname.com:8888/ssi/tnsnames.html', '
tnsnames.ora file.
'); htp.anchor('http://hostname.com:8888/ssi/df.html', '
File system information. (df -k)
'); htp.FormClose; htp.bodyClose; htp.htmlClose; end; / show errors Now, let’s take a closer look at how this Web page functions. The first option is designed to take a look at the Unix file system on the Unix server and then display the tnsnames.ora file information on the Web page. The second option issues a Unix df -k command and pipes the output into a flat file. What’s happening to cause this listing? Let’s begin by examining the following hypertext link: file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch12/423-430.html (3 of 7)4/03/2005 6:16:26
Oracle Databases on the Web:Using Java And LiveHTML With Oracle WebServer
htp.anchor('http://hostname.com:8888/ssi/tnsnames.html', '
tnsnames.ora file.
'); This hypertext link specifies that WebServer is to execute a procedure called tnsnames.html, located in the ssi directory, as specified in the WebServer directory mapping administration page. Listing 12.23 shows the contents of the tnsnames. html HTML document. Listing 12.23 An HTML document with LiveHTML. <TITLE>LiveHTML (Server Side Includes) Example
In Listing 12.23, you can see some LiveHTML. First, you can see the execution of a C shell script called tnsnames.csh. Listing 12.24 shows the contents of this script. Listing 12.24 C shell script to display tnsnames.ora file. #!/bin/csh file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch12/423-430.html (4 of 7)4/03/2005 6:16:26
Oracle Databases on the Web:Using Java And LiveHTML With Oracle WebServer
unalias rm rm *.out echo 'date' > /u99/dba/oracle/app/oracle/product/7.3.2/ows2/sample/ssi/ test1.out cat /etc/tnsnames.ora >> /u99/dba/oracle/app/oracle/product/7.3.2/ows2/sample/ssi/ test1.out Here we see the execution of several Unix commands. The first step deletes all *.out files on the Unix directory. The next command executes the Unix echo command to move the current date into a file called test1.out. Finally, the Unix cat command is used to append the tnanames.ora file after the data in the test1.out file. Now that the desired data has been written to the test1.out file, how does it make its way onto the Web page? Take a close look at the code in Listing 12.23. You should see the following:
This will take the listing and format it into a Web page for display on your browser. Figure 12.7 shows the output of this procedure.
Figure 12.7 Sample output listing with LiveHTML. To complete the picture, let’s take a look at Listing 12.25, which shows the HTML code generated to display the contents of the tnsnames.ora file. Listing 12.26 shows the actual contents of this file. Listing 12.25 HTML code for displaying a file on the host. file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch12/423-430.html (5 of 7)4/03/2005 6:16:26
Oracle Databases on the Web:Using Java And LiveHTML With Oracle WebServer
<TITLE>LiveHTML (Server Side Includes) Example
Listing 12.26 Contents of tnsnames.ora file. Wed Dec 11 10:29:23 EST 1996 ################ # Filename......: tnsnames.ora # Node..........: joey.world # Date..........: 26-Aug-96 01:00:24 ################ howard = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (COMMUNITY = TCPCOMM) (PROTOCOL = TCP) (Host = sandbox) (Port = 1600) ) ) file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch12/423-430.html (6 of 7)4/03/2005 6:16:26
Oracle Databases on the Web:Using Java And LiveHTML With Oracle WebServer
(CONNECT_DATA = (SID = DBAP) ) ) william = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (COMMUNITY = TCPCOMM) (PROTOCOL = TCP) (Host = sandbox) (Port = 1600) ) ) Here, you can see that the spooled output listing from the C shell script has been tagged for HTML display. This should complete the picture of how LiveHTML can be used to include Unix files and execute Unix scripts on a server.
Summary Now that we have looked at the usage for Java and LiveHTML in a WebServer environment, we can move on to the performance and tuning of the Oracle server. Regardless of how well you have tuned your WebServer engine, the bulk of the application work will still be done within the Oracle database. With the Oracle database becoming your weakest link, the following chapters are dedicated to improving the performance of the Oracle engine with an eye toward creating fast and efficient WebServer applications.
Previous Table of Contents Next
Products | Contact Us | About Us |
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch12/423-430.html (7 of 7)4/03/2005 6:16:26
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
CHAPTER 13 Using SQL*Net For WebServer Communication In a WebServer application, it is unusual for all of the databases to be on the same host as the WebServer engine. Rather, we expect to see Oracle databases distributed onto other host computers and Oracle’s SQL*Net used as the backbone for communications. Distributed Oracle systems enable load-balancing of the subsets of an application, giving each subset of data its own dedicated CPU. In a fully distributed Oracle environment, the WebServer exists as a standalone application on one server while the Oracle databases exist on remote servers. Whenever you have this type of distributed Oracle architecture, you must carefully examine the connectivity issues, so WebServer developers will be able to process data from all of the Oracle servers, regardless of their physical location. This requires a good understanding of SQL*Net, database links, table replication techniques, and distributed Oracle design. This chapter should give you a conceptual understanding of the role of SQL*Net and how it fits into the overall WebServer architecture.
Location Transparency And WebServer Connectivity Location transparency refers to the ability of a distributed database to function as a unified whole, appearing to developers as a single, unified Oracle database. Where the database resides, what type of database is used, or the required database access methods are all unimportant to end users, and a good design can greatly enhance the file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/431-434.html (1 of 3)4/03/2005 6:16:27
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
creation of WebServer applications. To understand location transparency, let’s assume that we have a parts inventory system with separate databases in San Francisco, New York, and Chicago. Let’s also assume that this is a horizontally partitioned database with inventory tables at each location. (A horizontal partition is a very large table that is split into smaller tables, each with the remote site’s data.) Because of this partitioning of the INVENTORY table, it is impossible to directly issue a single SQL command to get the contents from the INVENTORY table at all three locations. However, through the magic of SQL*Net, it’s possible to make remote tables appear as single unified tables. So, if a manager wishes to know the number of widgets on hand in all locations, she could issue the following SQL command to the distributed database manager: select count(*) from INVENTORY where partname = 'widget'; Because we have implemented data location transparency with SQL*Net, the end user does not know or care what databases are interrogated to satisfy his request. In the previous example of count(*) with location transparency, the end user has no interest in any individual databases when servicing the request, defining it as a global transaction. The transaction manager has the responsibility to query all of the distributed INVENTORY tables and collect the counts from each table, merging them into a single result set. In Oracle with SQL*Net, creating database links to the remote database and assigning a global synonym to the remote tables achieves location transparency. At the lowest level, computers are identified by an Internet Protocol (IP) address, which gives the computer a distinct number. An example would be 222.223.90.27. The IP address is associated with a server name using a Unix file called hosts. Table 13.1 shows how these items are associated within an Oracle environment. Table 13.1Associating database names and Unix addresses. Item
Unix Location
Example
Definition
Telnet
/etc/hosts
jason
Associates IP addresses with Telnet names
Database
/etc/oratab
custserv
Lists the Oracle system IDs
TNS Service
/etc/tnsnames.ora
custserv
Defines a protocol, server, and database
The three files—hosts, oratab, and tnsnames.ora—provide Oracle with the necessary information to uniquely identify each distributed database. In databases such as Oracle with SQL*Net, transparency is achieved by creating database links to remote databases and then assigning a global synonym to the fully qualified table name. Database links are created in Oracle by specifying three items: name of the database link, transparent network substrate (TNS) service name for the remote database (as defined in the SQL*Net tnsnames.ora file), and name of the Oracle user ID initiating the transaction on the remote server. Transparent network substrate is a fancy term for a single, common interface to all protocols that enables
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/431-434.html (2 of 3)4/03/2005 6:16:27
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
end users to connect to databases in physically separate networks. At the lowest level, TNS communicates to other databases with message-level send/receive commands. In the following example, omaha.com is the database link, and it connects to the omaha_server TNS service using the oracle_user_profile user ID: create public database link omaha.com connect to omaha_server using oracle_user_profile; Now that we have defined the location name, we can include tables from any of the omaha sites by qualifying the remote site name in the SQL query. In the following example, we join the EMPLOYEE table in omaha with our local SKILLS table: select
EMPLOYEE.employee_name, SKILLS.skills_date from EMPLOYEE@omaha.com, SKILLS where EMPLOYEE.emp_number = SKILLS.employee_number order by skills_date
;
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/431-434.html (3 of 3)4/03/2005 6:16:27
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
But how do we hide the fact that the EMPLOYEE table resides in omaha? To make the location of this table transparent to the developer, the DBA may assign synonyms for the EMPLOYEE table in omaha that would make the query appear to be a local table: create synonym EMPLOYEE for EMPLOYEE@omaha; The query can now be run with full location transparency: select from
EMPLOYEE.employee_name, SKILLS.skills_date EMPLOYEE, SKILLS
where EMPLOYEE.emp_number = SKILLS.employee_number order by skills_date ;
Note: It is important to understand which Oracle instances are servicing this request. Obviously, the omaha instance is responsible for retrieving the EMPLOYEE rows, but it is not so apparent that it’s the initiating instance’s job to perform the merge sort for the join. The local instance will also be the server that will sort the result set by skills_date. Therefore, if you are issuing this type of distributed request from a WebServer host, you need to ensure that your local WebServer database has enough space in the temporary tablespace and that the sort_area_size init.ora parameter is large enough to handle the sorting operations.
Oracle stored procedures can also be defined to allow for location transparency. Because the exact table name and TNS location is hidden inside the stored procedure, the developer who calls the file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/434-438.html (1 of 4)4/03/2005 6:16:28
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
routine can access the remote table without any reference to its physical location. For example, the following procedure could be defined to allow updates to the EMPLOYEE table in omaha: create procedure add_employee (emp_name char(8)) as begin insert into EMPLOYEE@omaha. values (emp_name); end; This procedure could be called with a single statement: add_employee("Rick Tytler"); Location transparency can be very useful for hiding the complexity of a distributed Oracle system, but there is much more to the story. Oracle Database Domains Most WebServer developers recognize the need to organize and manage remote locations of databases while providing location transparency to key developers. To Oracle, the term domain is used to define each remote database. Domains are especially important in situations of horizontal partitioning. Horizontal partitioning occurs when tables with identical names are kept in numerous locations. Domains can be used within Oracle to establish a logical hierarchy of physical locations for all of the databases that participate in the WebServer application. The sample database shown in Figure 13.1 establishes a domain hierarchy for remote databases.
Figure 13.1 Example of a WebServer TNS domain model. Each node in the network shown in Figure 13.1 assigns synonyms for all unique tables within the distributed network. For duplicate table structures existing at many locations, abbreviated domains can be created. Assume that both Japan and Ohio have an EMPLOYEE table, identical in structure but containing different rows. We could assign Oracle synonyms as follows: create synonym japan_employee for create synonym ohio_employee for
EMPLOYEE@hq.sales.asia.japan; EMPLOYEE@hq.mtfg.ohio;
Intersystem Connectivity With WebServer SQL*Net makes it easy to allow cross-database access, so the issue of intersystem connectivity must be understood. In a distributed Oracle system, you may see any of the following types of table partitioning: • Table Replication—Tables are copied to remote locations using Oracle’s snapshot facility. • Vertical Partitioning—Tables are sliced vertically, placing different columns of the same logical table in remote locations. • Horizontal Partitioning—Tables are sliced by row, placing logically related rows in different physical locations. • Functional Partitioning—Different functional tables exist in different remote locations.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/434-438.html (2 of 4)4/03/2005 6:16:28
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
One very common method of Oracle database distribution is to use horizontal partitioning, where different rows exist at remote locations and SQL*Net makes the remote tables appear as a single table. For example, employee service organizations commonly allow their remote sites to maintain employee information and maintain a location-transparent access mode to every employee, regardless of their physical location. Horizontal partitioning is achieved by taking a subset of each remote site’s EMPLOYEE table and populating a master lookup table that is accessible from any node in the distributed system (see Figure 13.2).
Figure 13.2 Horizontal data partitioning of a master lookup table for a distributed WebServer application. In a WebServer system, the Unix cron utility can be used to schedule a periodic refresh of the master table. cron is short for chronological, and it’s the name of the Unix utility used to schedule jobs. As such, cron is a time-dependent task activation utility that starts tasks at predetermined dates and times. An SQL script would automatically extract employee_name from the remote site and repopulate the master EMPLOYEE table, leaving the employee details at the remote site. The Oracle SQL might look like this: /*
Delete remote rows in the master table... */
delete from employee@master where location = :our_site; /*
Repopulate the master table...
*/
select employee_name, ":our_site" from employee@:OUR_SITE as insert into employee@master values employee_name, site_name; Once populated, the master lookup table can be accessed by any node and used to redirect the database query to the appropriate remote database for employee detail (see Figure 13.3).
Figure 13.3 Example of location transparency for a distributed WebServer application. Because of dynamic substitution in SQL, a common application can be made to access any employee in the federation, regardless of the location and without any coding changes. For a complete description of these techniques, refer to the text Managing Distributed Databases by Donald K. Burleson, published by Wiley-QED Publishing. Now that we understand how to make each location transparent to the WebServer application, let’s explore the internals of Oracle’s SQL*Net. SQL*Net is a powerful tool that allows many different configurations. A good knowledge of SQL*Net and all of its possible configurations will file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/434-438.html (3 of 4)4/03/2005 6:16:28
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
greatly aid WebServer administrators in providing fast and seamless inter-database communications.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/434-438.html (4 of 4)4/03/2005 6:16:28
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
Possibly the smartest IT investment. Possibly the smartest IT investment.
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Internals Of Oracle’s SQL*Net In its most basic form, SQL*Net is a software tool that enables a network of Oracle clients and servers to communicate transparently on top of any underlying network topology or protocol using SQL. Although SQL*Net is a robust and sophisticated tool, you must appreciate the inherent complexity that goes along with the flexibility of SQL*Net. Due to the sophisticated architecture of SQL*Net, it’s not trivial to install SQL*Net on the WebServer or any of the remote servers. Because we are dealing with a WebServer front end, it’s important to note that the WebServer host will be the client, while the remote Oracle databases will be the servers. For a general overview of the SQL*Net architecture, let’s begin by looking at the control files for SQL*Net. In Unix systems, the following four files are necessary to operate SQL*Net 2.0: • tnsnames.ora—Used for outgoing database requests, this file contains all of the database system identifiers (SIDs) running on the processor, as well as the domain name, protocol, host, and port information. When a new database is added to a server, you must update this file (changes to tnsnames.ora become effective instantly). Note that the SQL*Net version 1.0 equivalent to Oracle’s tnsnames.ora file is the /etc/oratab file. • listener.ora—This file contains a list of local databases for use by incoming connections. When you add a new destination database to a Unix host, you must also add it to this file.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/438-442.html (1 of 3)4/03/2005 6:16:29
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
• hosts—This file lists all of your network addresses. • services—This file lists all of the SQL*Net services. On some flavors of Unix, such as HP-UX, these files are located in the /etc directory. For Solaris Unix, the .ora files are located in the /var/opt/ oracle directory. In SQL*Net version 2.0, Oracle has added several important enhancements. Aside from the badly needed bug fixes, SQL*Net now allows access to multiple communities. A community is a group of computers that share a common communications protocol (such as TCP/IP to LU6.2). In addition, the Oracle7 database engine now allows for the creation of a multithreaded server (MTS) for servicing incoming data requests. In an MTS, all communication to databases is handled through a single dispatcher, rather than a separate process being spawned for each incoming database connection, as is the case with SQL*Net version 1.0. When upgrading from SQL*Net 1.0 to SQL*Net 2.0, you should be aware of subtle differences between how the two versions handle communications. (See Figure 13.4.) SQL*Net version 1.0 uses an orasrv component on the destination database to listen for incoming requests, while SQL*Net 2.0 uses a process called tnslsnr (TNS listener). In addition, SQL*Net 1.0 cannot use an MTS.
Figure 13.4 A comparison of the two versions of SQL*Net. When a connection is made to SQL*Net, it passes the request to its underlying layer—the TNS—where the request is transmitted to the appropriate server. At the server, SQL*Net receives the request from the TNS and passes the SQL to the database. On the client side, the User Programmatic Interface (UPI) converts SQL to associated parse, execute, and fetch statements. The UPI parses the SQL, opens the SQL cursor, binds the client application, describes the contents of returned data fields, executes the SQL, fetches the rows, and closes the cursor. Oracle attempts to minimize messages to the server by combining UPI calls whenever possible. On the server side, the Oracle Programmatic Interface (OPI) responds to all possible messages from the UPI and returns requests. All of this work is done after the request has been spawned through the Web Listener and the Web Request Broker. Hence, there are many intermediate steps that a WebServer request must perform before actually retrieving the Oracle data. To further complicate matters, no UPI exists for server-to-server communication. Instead, a Network Programmatic Interface (NPI) resides at the initiating server, and the responding server uses its OPI for the request. SQL*Net supports network transparency so that the network structure may be changed without affecting the SQL*Net application. Location transparency is achieved with database links and synonyms.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/438-442.html (2 of 3)4/03/2005 6:16:29
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
Let’s trace a sample WebServer data request through SQL*Net. The following steps are performed: 1. A request is intercepted by the Web Listener, which spawns a process connection to the Web host processor. 2. The request is then passed to the Web Request Broker (WRB), or the Common Gateway Interface (CGI) for WebServer version 1.0. 3. The request is then directed to the SQL*Net listener on the WebServer host. For PL/SQL requests, the stored procedure is then extracted from the WebServer’s local Oracle database. 4. The stored procedure is then interpreted, and all references to remote Oracle databases are resolved. Requests are sent to each of the remote databases, where their SQL*Net listeners intercept and service the requests. 5. The Oracle transaction manager then receives the data from each of the remote requests and performs all necessary sort and merge operations, delivering a single solution set for the SQL request. 6. The solution set is then passed back to the Web Request Broker (or CGI), which, in turn, passes the data back through the Web Listener to the requesting WebServer client. But wait, it gets even more complex. As each data request is processed by the WebServer host, SQL*Net looks for the link name in the database link table (DBA_DB_LINKS) and extracts the service name. The service name is then located in the tnsnames.ora file, and the host name is extracted. Once again, we have a threestage process beginning with the link name referencing the service name, and then the service name referencing the host name.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/438-442.html (3 of 3)4/03/2005 6:16:29
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
You think IT strategy, we’ll think details. You think IT strategy, we’ll think details.
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
In Unix environments, the host name is usually found in a host file (/etc/hosts), and the Internal Protocol (IP) address is gathered. In the following example, omaha_server might translate into an IP address of 143.32.142.3. The following four steps illustrate how SQL*Net takes a remote request and translates it into the IP address of the destination database: 1. Issues a remote request, and checks the database link called omaha. select * from EMPLOYEE@omaha; 2. The database link gets the service name (omaha_server_d) using the link_name (omaha). create public database link omaha connect to omaha_server_d; 3. tnsnames.ora gets the SID name (omaha_sid) using service name (omaha_server_d). omaha_server_d = (description=(address=(protocol=tcp) (host=bluegill) (port=1521) (connect_data=(sid=omaha_sid) (server=dedicated))) 4. /etc/hosts gets the IP address (143.32.142.3) using the SID name (omaha_sid). 143.32.142.3
omaha_sid
omaha_server.corporate.com
As you can see, this translation occurs in a multistage process. The tnsnames.ora file specifies the name of the host containing the destination database. For Unix environments, this host name is then looked up in the /etc/hosts file to get the IP address of the destination box. file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/442-445.html (1 of 3)4/03/2005 6:16:29
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
Note that the service name is looked up in tnsnames.ora — if the service exists, the IP address is found in the /etc/hosts file, and a communications request is sent to the destination IP address. Both of the entries in this file connect to omaha, but omaha_server_d directs SQL*Net to spawn a dedicated process, while omaha_server uses the multithreaded server component because a shared server is specified. Now that you have the tnsnames.ora and /etc/hosts files in place, you can include any tables from the omaha sites by qualifying the remote site name in the SQL query. select EMPLOYEE.employee_name, SKILLS.skills_date from EMPLOYEE@omaha, SKILLS where EMPLOYEE.emp_number = SKILLS.employee_number; Note that this query joins two tables at different locations, and the database link called omaha determines how the Oracle connection will be established on the destination system. However, regardless of how the connection is made to the destination, the user ID must have select privileges against the EMPLOYEE table, or this query will fail. Application Connection With SQL*Net Connections to remote databases can be made by specifying either the service names or connect strings. For SQL*Net, connect strings use the full connection, specifying the protocol:server: database. In the following example, the t: means a TCP/IP connection, host: is the name of the remote processor, and database: is the name of the databases on the host processor. The format for the two selections are: • Connect via a service name—emp@my_db • Connect via a server connect string—sqlplus /@t:host:database Connect strings are stored in the DBA_DBLINKS table and are created with the create database link command, as follows: create public database link ny_emp for ny_emp@t:myhost:mydatabase; SQL*Net can establish database communications via three methods: remote connection, remote request, or distributed request. A remote connection is the easiest way to make a database connection. The sending database simply makes a request by specifying a table name suffixed by @. SQL*Net takes it from there, seamlessly accessing the remote database and returning the data to the initiating system. Communication is established by making a distributed request to a remote database. Within Oracle, @ specifies the remote database name, but the functionality of the @ operator depends on where it’s used. Here’s an example: sqlplus scott/tiger@omaha select count(*) from EMPLOYEE; count(*) —————— 162 In this request, scott is using SQL*Plus to connect to the omaha database, and @omaha is the service name, as defined in the tnsnames.ora file. SQL*Net recognizes this as a remote connection and determines the appropriate linkage to establish communications with omaha. Internally, Oracle will check the tnsnames.ora file to ensure that omaha is a valid destination. However, there file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/442-445.html (2 of 3)4/03/2005 6:16:29
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
is another way of connecting to omaha from the same database. This is called a remote request. Following is an example of a remote request: sqlplus scott/tiger select count(*) from EMPLOYEE@omaha; count(*) ——————— 162 Unlike a remote connection made directly from SQL*Plus, the remote request has scott connecting to the local copy of SQL*Plus to specify the remote table (in this case, EMPLOYEE@omaha). For a remote request to work, a database link must define omaha. A database link is a connection pathway to a remote database that specifies the service name of the remote database. Without the database link, the following request would fail: sqlplus jenny_burleson/secret_password select count(*) from EMPLOYEE@omaha; This request will give you the following error message: ORA-02019: Connection description for remote database not found. This error message results from the way Oracle defines the @ operator for remote connections. When entering an Oracle service, such as SQL*Plus from the Unix command prompt, the @ operator will go directly
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/442-445.html (3 of 3)4/03/2005 6:16:29
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
Stop the duel-boot Stop the duel-boot
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Let’s take a closer look at a database link. In this simple example, no mention is made of the user ID used to establish the connection on the remote database. Because scott is the user connecting to SQL*Plus, scott will be the user ID when the remote connection is established to the omaha database. Therefore, scott must have select privileges against the EMPLOYEE table in omaha in skills for the query to work properly. scott’s privileges on the initiating Oracle database have no bearing on the success of the query.
Note: If you are using the Oracle Names facility, you must be sure that your database service names are the same as the global_databases_names and the domain init.ora parameter. file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/445-448.html (1 of 4)4/03/2005 6:16:30
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
In cases where select security is not an issue, you can enhance the database link syntax to include a remote connect description: create database link omaha using 'omaha' connect to SCOTT1 identified by TIGER1; This way, all users who specify the omaha database link will connect as scott1 // and will have whatever privileges scott1 // has on the omaha system. Once you establish a communications pathway to the remote database, it is often desirable to implement location transparency. In relational databases such as Oracle, you can obtain location transparency by creating database links to the remote database and then assigning a global synonym to the remote tables. The database link specifies a link name and an SQL*Net service name. You can create database links with a location suffix that is associated with a host name (in this example, omaha_server). You can use database links to allow applications to point to other databases without altering the application code. For data warehousing applications, you can replicate a table on another machine and establish links to enable the application to point transparently to the new box containing the replicated table. To see the links for a database, query the Oracle dictionary in the following manner: select distinct db_link from DBA_DB_LINKS; Keep in mind that SQL*Net bypasses all operating system security settings when it connects to a database. All user accounts identified externally (that is, without an Oracle password) will not be allowed in SQL*Net transactions unless the init.ora parameter is changed. The identified externally clause (sometimes called OPS$) in Oracle version 6 allowed the operating system to manage passwords, but because SQL*Net bypasses the operating system, impostor accounts could be created from other platforms. For example, a Unix user running a PC-based Unix operating system such as Coherent could set their user ID to anyone they desired, and then connect with SQL*Net to any remote database with all database privileges consistent with the user ID. Consequently, Oracle now recommends that identified externally accounts be forbidden for distributed connections. It is interesting to note that Oracle will allow you to create accounts with an OPS$ prefix. Therefore, the operating system can manage its passwords, while you also have passwords within Oracle. For example, assume the following user definition:
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/445-448.html (2 of 4)4/03/2005 6:16:30
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
create user ops$scott identified by tiger; Assuming that scott has logged onto the operating system, scott could enter SQL*Plus either with or without a password, as follows: sqlplus / sqlplus scott/tiger This ability to connect directly to Oracle presents a confounding issue with password management. Because two sets of passwords exist—one in the operating system and another in Oracle—you may need a third-party tool to keep the passwords synchronized. Understanding The SQL*Net Listener Each version of Oracle has its own listener process. For SQL*Net version 1.0, the listener process is called orasrv, and the SQL*Net version 2.0 listener process is called tnslsnr. Using the Unix ps command, you can see the listener processes running on your server, as shown in Listing 13.1. Listing 13.1 A sample Unix ps command. ps -ef|grep ora oracle 1201 1 80 LISTENER -inherit oracle 934 1 3 oracle 1443 1 83 oracle/app/orac oracle 1231 1 80 oracle/app/orac
Nov 13 0:02
/u00/oracle/product/7.3.2/bin/tnslsnr
Nov 13 0:00 Nov 13 0:32
orasrv /u00/oracle/product/7.3.2/bin/oraweb -C u00/dba/
Nov 13 0:02
/u00/oracle/product/7.3.2/bin/wrb2 16 4 /u00/dba/
From Listing 13.1, we can see the SQL*Net listeners, WebServer listener, and Web Request Broker running on this server. To see what the Oracle listeners are doing, Oracle provides a series of listener commands, which include: • reload—Refreshes the listener • start—Starts the listener file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/445-448.html (3 of 4)4/03/2005 6:16:30
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
• stop—Stops the listener • status—Shows the status of the listener • services—Shows all connected services for the listener There are three listeners that accept and activate these commands. The activation commands are as follows: • tcpctl—Command to the SQL*Net v 1 Listener • lsnrctl—SQL*Net v 2 Listener • wlctl—Web Listener
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/445-448.html (4 of 4)4/03/2005 6:16:30
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Therefore, if we wanted to check the status of the SQL*Net version 2.0 Listener, we could issue the command lnsrctl stat. Listing 13.2 shows the output of the lsnrctl stat command. Listing 13.2 A sample output from the SQL*Net Listener command. [oracle]ram2: lsnrctl stat LSNRCTL for HPUX: Version 2.0.15.0.0 - Production on 16-SEP-94 15:38:00 Copyright (a)
Oracle Corporation 1993.
All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=TCP)(HOST=ram2)(PORT=1521)) STATUS of the LISTENER ———————————— Alias LISTENER Version TNSLSNR for HPUX: Version 2.0.15.0.0 - Production Start Date 29-AUG-94 13:50:16 Uptime 18 days 1 hr. 47 min. 45 sec Trace Level off Security OFF Listener Parameter File /etc/listener.ora Listener Log File /usr/oracle/network/log/listener.log Services Summary... dev7dba has 1 service handlers ram2dba has 1 service handlers The command completed successfully lsnrctl services
- lists all servers and dispatchers
[oracle]bluegill: lsnrctl services LSNRCTL for HPUX: Version 2.0.15.0.0 - Production on 16-SEP-94 15:36:47 Copyright (a)
Oracle Corporation 1893. All rights reserved.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/448-450.html (1 of 3)4/03/2005 6:16:30
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
Connecting to (ADDRESS=(PROTOCOL=TCP)(HOST=bluegill)(PORT=1521)) Services Summary... ftdab000 has 4 service handlers DISPATCHER established:1 refused:0 current:2 max:55 state:ready D001 (machine: bluegill, pid: 4146) (ADDRESS=(PROTOCOL=tcp)(DEV=5)(HOST=141.123.224.38)(PORT=1323)) DISPATCHER established:1 refused:0 current:2 max:55 state:ready D000 (machine: bluegill, pid: 4145) (ADDRESS=(PROTOCOL=tcp)(DEV=5)(HOST=141.123.224.38)(PORT=1321)) DISPATCHER established:0 refused:0 current:1 max:55 state:ready D002 (machine: bluegill, pid: 4147) (ADDRESS=(PROTOCOL=tcp)(DEV=5)(HOST=141.123.224.38)(PORT=1325)) DEDICATED SERVER established:0 refused:0 The command completed successfully As a service request is intercepted by an Oracle server, the listener may direct the request via a dedicated server, an MTS, or an existing process (also known as a prespawned shadow). The key is whether the connection contacts the listener via a service name or bypasses the listener with the two_task connect string. If the listener is contacted as part of the connection and the MTS parms are defined to init.ora, the client will use the MTS. There are five basic listener commands: reload, start, stop, status, and services. Based on the request, the listener decides whether to dispatch a connection to a dedicated-server process (which it spawns) or to use the MTS. The programmer has several options when deciding how Oracle will manage the process. Dedicated requests can be specified by a version 1.0 connect string or by using a service name that specifies server=dedicated in the tnsnames.ora file. Managing SQL*Net Connections Listing 13.3 describes some of the utilities you can use to manage SQL*Net sessions effectively. You should be aware that some of the examples in this section are operation system–independent and may not apply to your environment. Listing 13.3 Commit point strength. commit.sql - Reports the commit point strength for the database. set feedback column name column type column value
off format a30 heading 'Name' format a7 heading 'Type' format a60 heading 'Value'
prompt Commit Point-strength Report Output: prompt prompt select name, decode(type,1,'boolean', 2,'string', 3,'integer', 4,'file') type, replace(replace(value,'@','%{sid}'),'?','%{home}') value from v$parameter where name = 'commit_point_strength';
Previous Table of Contents Next
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/448-450.html (2 of 3)4/03/2005 6:16:30
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/448-450.html (3 of 3)4/03/2005 6:16:30
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Managing Oracle’s Multithreaded Server One of the problems with SQL*Net version 1.0 was that each incoming transaction was spawned by the listener as a separate operating system task. With SQL*Net version 2.0, Oracle now has a method for allowing the listener connection to dispatch numerous subprocesses. With the MTS, all communications to a database are handled through a single dispatcher instead of separate Unix process IDs (PIDs) on each database. This translates into faster performance for most online tasks. Even local transactions will be directed through the MTS, and you will no longer see a PID for your local task when you issue the Unix command ps -ef|grep oracle. However, be aware that the MTS is not a panacea, especially at times when you want to invoke a dedicated process for certain WebServer connections. For a process that has little idle time, such as an intensive table update with WebServer (and also Pro*C programs or I/Ointensive SQL*Forms applications), you will get better performance if you bypass the MTS and use a dedicated process connection. In general, the MTS offers benefits, such as reduced memory use, fewer processes per user, and automatic load balancing. Remember the following rules of thumb when initially starting the MTS: • The MTS is governed by the init.ora parameters. If no MTS parms are present in init.ora, the MTS is disabled. • The MTS is used when the MTS parms are in the init.ora and requests are made by service name (such as @my_database). In other words, you must retrieve the rowid of all version 1.0 connect strings (such as t:unix1:my_database). • Each user of the MTS requires 1 K of storage, so plan to increase your shared_pool_size.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/450-453.html (1 of 3)4/03/2005 6:16:31
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
• The V$QUEUE and V$DISPATCHER system tables indicate whether the number of MTS dispatchers is too low. Even though the number of dispatchers is specified in the init.ora file, you can change it online in SQL*DBA with the alter system command, as follows: SQLDBA> alter system set mts_dispatchers = 'TCPIP,4'; • If you encounter problems with the MTS, you can quickly regress to dedicated servers by issuing an alter system command. The following command turns off the MTS by setting the number of MTS servers to 0: SQLDBA> alter system set mts_servers=0; • In order to use OPS$, you must set two init.ora values to true (the default is false), as follows: remote_os_authent = true remote_os_roles = true • When both SQL*Net 1.0 and 2.0 are installed, the user may connect to the server via a dedicated server or the MTS. However, you cannot stop and restart the listener when connecting via the MTS. You must connect to SQL*DBA with a dedicated server. • In some cases, the instance must be bounced if the listener is stopped, or it will restart in dedicated mode. Whenever an instance is to be bounced, stop the listener, shut down the instance, restart the listener, and start up the instance. The listener reads the MTS parameters only if it’s running before startup of the instance. Therefore, bouncing the listener will disable the MTS. Managing The Listener Processes The listener is a software program that runs on each remote node and “listens” for any incoming database requests. When a request is detected, the listener may direct the request to any of the following: • Dedicated server • Multithreaded server • Existing process or prespawned shadow Note that the configuration of an Oracle listener is a direct result of the parameters specified in the startup deck for the Oracle database. This parameter file is called init.ora and will contain the parameters used to define the multithreaded server and listener, as shown in Listing 13.4. Listing 13.4 init.ora parameters for the multithreaded server. #———————————# Multithreaded Server #———————————MTS_DISPATCHERS
= "tcp,3"
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/450-453.html (2 of 3)4/03/2005 6:16:31
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
MTS_LISTENER_ADDRESS = "(ADDRESS=(PROTOCOL=tcp) (HOST=bluegill) (PORT=1521))" MTS_MAX_DISPATCHERS
= 5
MTS_MAX_SERVERS
= 20
#—————————————# Distributed systems options #—————————————DISTRIBUTED_LOCK_TIMEOUT
= 60
DISTRIBUTED_RECOVERY_CONNECTION_HOLD_TIME = 200 DISTRIBUTED_TRANSACTIONS
= 6
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/450-453.html (3 of 3)4/03/2005 6:16:31
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
Basic
home
account info
subscribe
login
search
FAQ/ site help map
GO
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Managing Two-Phase Commits (2PCs) In some cases, you may want your WebServer application to issue updates against two or more remote databases in a single SQL command. When a distributed update (or delete) has finished processing, SQL*Net will coordinate commit processing, which means that the entire transaction will roll back if any portion of the transaction fails. The first phase of this process is to issue a prepare phase to each node, followed by the commit, and then terminated by a forget phase. If a distributed update is in the process of issuing the 2PC and a network connection breaks, Oracle will place an entry in the DBA_2PC_PENDING table. The recovery background process (RECO) will then roll back or commit the good node to match the state of the disconnected node to ensure consistency. You can activate RECO via the alter system enable distributed recovery command. The DBA_2PC_PENDING table contains an advise column that directs the database to either commit or roll back the pending item. You can use the alter session advise syntax to direct the 2PC mechanism. For example, to force the completion of an insert, you could enter the following: alter session advise commit; insert into payroll@omaha. .. ; When a 2PC transaction fails, you can query the DBA_2PC_PENDING table to check the state column. You can enter SQL*DBA and use the Recover In-Doubt Transaction dialog box to force either a rollback or a commit of the pending transaction. If you do this, the row will disappear from DBA_2PC_PENDING after the transaction has been resolved. If you force the transaction the wrong way (for example, rollback when other nodes committed), RECO will detect the problem, set the mixed column to yes, and the row will remain in the DBA_2PC_PENDING table. Internally, Oracle examines the init.ora parameters to determine the rank that the commit processing will take. The commit_point_strength init.ora parameter determines which of the distributed databases is to be the commit point site. In a distributed update, the database with the largest value of commit_point_strength will be the commit point site. The commit point site is the database that must successfully complete before the transaction is updated in the other databases. Conversely, if a transaction fails at the commit point site, the entire transaction will be rolled back at all of the other databases. In general, the commit point site should be the database that contains the most critical data. Listing 13.5 shows a script that identifies 2PC transactions that have failed to complete. Listing 13.5 pending.sql reports on any pending distributed transactions.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/453-456.html (1 of 4)4/03/2005 6:16:32
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
set pagesize 999; set feedback off; set wrap on; column local_tran_id column global_tran_id column state column mixed column advice select from skills
format format format format format
a22 a50 a16 a5 a5
heading heading heading heading heading
'Local Txn Id' 'Global Txn Id' 'State' 'Mixed' 'Advice'
local_tran_id,global_tran_id,state,mixed,advice dba_2pc_pending by local_tran_id;
Viewing SQL*Net Sessions On systems running SQL*Net version 2.0, the following SQL*Plus script can be used to query the number of dedicated and shared servers on the system. For example, Listing 13.6 shows an SQL*Plus script to view all sessions. Listing 13.6 session.sql displays all connected sessions. set echo off; set termout on; set linesize 80; set pagesize 60; set newpage 0; ttitle "dbname Database|UNIX/Oracle Sessions"; spool /tmp/session set heading off; select 'Sessions on database '||substr(name,1,8) from v$database; set heading on; select substr(b.serial#,1,5) ser#, substr(b.machine,1,6) box, substr(b.username,1,10) username, substr(b.osuser,1,8) os_user, substr(b.program,1,30) program from v$session b, v$process a where b.paddr = a.addr and type='USER' skills by spid; ttitle off; set heading off; select 'To kill, enter SQLPLUS> ALTER SYSTEM KILL SESSION', ''''||'SID, SER#'||''''||';' from dual; spool off; [oracle]ram2: sqlx session Wed Sep 24 Page 1 ram2db Database Sessions for SQL*Net SERVER
Oracle user
——————
——————————
O/S
User
Machine Program
————
————
—————————————
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/453-456.html (2 of 4)4/03/2005 6:16:32
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
DEDICATED
JAME_GASTON
jgaston
ram2
sqldba@ram2 (Pipe Two-Task)
DEDICATED
LINDA_ODELL
lodell
ram2
runform30@ram2 (Pipe TwoTask)
DEDICATED
RICK_WAHL
rwahl
ram2
sqlplus@ram2 (Pipe Two-Task)
DEDICATED
MARK_REULBACH
mreulbach
dlt2
sqlplus@clt2 (TNS interface)
DEDICATED
BOB_PAPAJ
bpapaj
ram2
?
DEDICATED
DEB_SCHUMACHER dschumacher ram2
runmenu50@ram2 (Pipe TwoTask)
DEDICATED
KAREN_CHAN
kchan
sqlplus@ensc (TCP Two-Task)
DEDICATED
MARC_MASCARO
mmascaro
DEDICATED
KELVIN_CONNOR
kconnor
ram2
sqlplus@ram2 (Pipe Two-Task)
DEDICATED
STEVE_WOHL
swohl
ram2
sqlforms30@ram2 (Pipe TwoTask)
DEDICATED
CRISTAL_WONG
cwong
ram2
RUN_USEX@ram2 (Pipe TwoTask)
xnsc
@ram2 (TCP Two-Task)
C:\PB3\PBSYS030.DLL
11 rows selected. Here we see each of the four types of SQL*Net connections: • Pipe Two-Task—Used for internal tasks (SQLPLUS /). • TNS Interface—Used when a connection is made with a v2 service name (SQLPLUS /@ram2). • TCP Two-Task—Used when a connection is made with a v1 connect string (SQLPLUS /@t: ram2:ram2db). • PC Connection Task—Denoted by the PC DLL name (c:\pb3\pbsys030.dll, which was initiated via PowerBuilder DLL).
Summary Now that we have reviewed the basics of distributed Oracle database management, you should have a good idea of how a distributed Oracle database can be integrated for use by a WebServer application by using database links and SQL*Net connections. While we can only gloss over the high points of SQL*Net in this chapter, sophisticated tools such as SQL*Net 2.0 require a great deal of knowledge and skill to use effectively. As systems continue to evolve into complex distributed networks, interdatabase communications will continue to become more complex and require more sophisticated tools. Objectorientation promises to make interdatabase communications simple, but the DBA in the trenches will continue to struggle with implementing everyday distributed database communications. In the following chapters, we will take a look at Oracle database design issues to ensure that the Oracle database portion of the WebServer application does not become the bottleneck in the overall system.
Previous Table of Contents Next
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/453-456.html (3 of 4)4/03/2005 6:16:32
Oracle Databases on the Web:Using SQL*Net For WebServer Communication
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch13/453-456.html (4 of 4)4/03/2005 6:16:32
Oracle Databases on the Web:Logical Design For WebServer Applications
Basic
home
account info
subscribe
login
search
FAQ/ site help map
GO
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
CHAPTER 14 Logical Design For WebServer Applications There are many books containing tips on the effective design of Oracle systems, but many of these texts are purely theoretical and fail to take into account the real-world issues involved in designing a high-performance Oracle database. In this chapter, we’ll take a real-world approach toward designing WebServer applications and discuss the importance of system response time.
Normalization And Modeling Theory For Oracle As we know, there are five basic types of data relationships that must be modeled when designing any Oracle database: • • • • •
one-to-one one-to-many many-to-many recursive many-to-many “is a” (ISA)
The effective WebServer designer must be able to represent these five types of data relationships in a sensible way, while ensuring acceptable Oracle database performance. This chapter focuses on one-to-many and many-to-many relationships. Redundancy And Database Design An Oracle database with either one-to-many or many-to-many relationships has file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch14/457-460.html (1 of 3)4/03/2005 6:16:32
Oracle Databases on the Web:Logical Design For WebServer Applications
redundant foreign keys embedded in the tables to establish logical relationships between entities. The redundant duplication of foreign keys in subordinate tables creates the data relationships, making it possible to join tables together and relate the contents of the data items in the tables. As the size of the database increases, data redundancy can become a major problem. Today, many users create very large databases, many of which contain trillions of bytes. For databases of this size, a single table can contain more than a billion rows, and the introduction of a single new column to a table could represent thousands of dollars in additional disk expense. Data redundancy is detrimental for two reasons. First and foremost, duplicating the redundant material consumes disk storage space. Second, updating redundant data requires extra processing. Redundant duplication of very large and highly volatile data items can cause huge processing bottlenecks. However, this does not imply that redundancy is always undesirable. Performance is still an overriding factor in most systems. Proper control of redundant information implies that redundant information may be introduced into any structure, as long as the performance improvements outweigh the additional disk costs and update problems. Since the first publication of Dr. E. F. Codd’s 1993 research paper, Providing OLAP (Online Analytical Processing) to User-Analysts: An IT Mandate, database designers have attempted to find an optimum way of structuring tables for low data redundancy. Codd’s rules of normalization often guide designers to create logically correct table structures with no redundancy, but many designers have found that performance demands often dictate the introduction of duplicate table data. This is especially true for distributed Oracle databases. Any node in a distributed database may want to browse a list of customers from another node without establishing a connection to it. In addition, the technological complexity inherent in Oracle’s two-phase commit often necessitates the widespread replication of entire tables or selected columns from tables. However, the distributed database designer does not have free reign to introduce redundancy anywhere in the enterprise. Redundancy always has a price tag, whether it is the cost of the disk storage or the cost of maintaining a parallel update scheme. Figure 14.1 shows a strategy for analyzing the consequences of data redundancy.
Figure 14.1 A comparison of size versus volatility for redundant data. In Figure 14.1, a boundary line lies within a range between the size of a redundant data item and the frequency in which the data item updates. The size of the data item relates to the disk costs associated with storing the item, and the frequency of update is associated with the cost of keeping the redundant data current, whether by replication techniques or by two-phase commit updates. Because the relative costs are different for each hardware configuration and for each application, this boundary may be quite different depending on the type of application. The rapid decrease in disk storage costs
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch14/457-460.html (2 of 3)4/03/2005 6:16:32
Oracle Databases on the Web:Logical Design For WebServer Applications
means that the size boundary is only important for very large-scale redundancy. A large, frequently changing item (for example, street_address) is not a good candidate for redundancy. But large static items (for example, service_history) or small, frequently changing items (such as product_price) may be acceptable for redundancy. Small static items (for example, gender) represent ideal candidates for redundant duplication.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch14/457-460.html (3 of 3)4/03/2005 6:16:32
Oracle Databases on the Web:Logical Design For WebServer Applications
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
One-To-Many Data Relationships One-to-many relationships exist in many real-world situations. Many entities that possess one-to-many relationships can be removed from the data model, eliminating some join operations. The basic principle here is simple: Redundant information avoids expensive SQL joins and yields faster processing. But remember, we must deal with the issue of additional disk storage and the problems associated with updating the redundant data. For example, consider the Entity/Relation (E/R) model shown in Figure 14.2.
Figure 14.2 A fully normalized E/R model sales database. In Figure 14.2, we see that the structure is in pure Third Normal Form. Notice that the CITY and STATE tables exist because each state has many cities and each city has many customers. This model works for most transactions in an online transaction processing (OLTP) system. However, this high degree of normalization would require the joining of the CITY and STATE tables each time address information is requested, forcing some SQL requests to perform very slowly. Consider a query to display the state_bird for all orders that have been placed for birdseed. This is a cumbersome query that requires the joining of six tables, as shown in Listing 14.1. Listing 14.1 Joining six tables. file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch14/460-464.html (1 of 4)4/03/2005 6:16:33
Oracle Databases on the Web:Logical Design For WebServer Applications
select state_bird from STATE, CITY, CUSTOMER, ORDER, QUANTITY, ITEM where item_name = 'BIRDSEED' and ITEM.item.nbr = QUANTITY.item.nbr AND QUANTITY.order_nbr = ORDER.order_nbr AND ORDER.cust_nbr = CUSTOMER.cust_nbr AND CUSTOMER.cust_city = CITY.cust_city AND CITY.state_name = STATE.state_name; With Oracle and the rule-based optimizer, this type of complex join guarantees that at least one table is read front to back using a full-table scan, and a full-table scan may slow down even the best WebServer application. This is a shortcoming of Oracle’s rule-based optimizer, because an SQL optimizer should generally avoid a full-table scan whenever indexes are present (except, of course, when the table is very small). This situation might be avoided by using Oracle hints with the cost-based optimizer to determine the optimal path to this data. A hint is an extension of Oracle’s SQL that directs the SQL optimizer to change its normal access path. But what happens if you are designing a data warehouse and your goal is to simplify the data structure by removing several of the one-to-many relationships? For example, you may choose to eliminate the “one” side of a relationship by copying the data columns into the “many” side of the relationship. This is a very common approach in the design of denormalized STAR schemas for use by Oracle 7.3 data warehouses. (We’ll talk more about STAR schemas later in this chapter.) However, adding redundancy poses two issues. First, you need additional disk space for the redundant item, and second, you need to provide a technique to update the redundant item if it needs to be changed. In our example, one solution is to build a table of columns that rolls the CITY and STATE tables into the CUSTOMER table. Table 14.1 assumes that the STATE table contains 50 rows, the CITY table has 2,000 rows, and the CUSTOMER table has 10,000 rows. Table 14.1Redundancy matrix to determine optimal normalization. Column
Size
Duplication
Total Space
Change
state_bird
10
10,000
100,000
Rare
state_flower
10
10,000
100,000
Rare
region_name
2
10,000
20,000
Never
cost_of_living
8
10,000
80,000
Quarterly
10
10,000
100,000
city_mascot
Rare
From Table 14.1, you can see that the CITY and STATE tables can be removed file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch14/460-464.html (2 of 4)4/03/2005 6:16:33
Oracle Databases on the Web:Logical Design For WebServer Applications
entirely for a total savings of 400,000 bytes (refer to Figure 14.3). What about the cost_of_living field? If we choose to eliminate the CITY table, and duplicate cost_of_living in every CUSTOMER table row, it would be necessary to visit each and every CUSTOMER row—which means changing the cost of living 10,000 times. Before this change, the following SQL was used to update each CITY table: update CITY set cost_of_living = :var1 where CITY = :var2; 2000 rows updated
Figure 14.3 A denormalized E/R model sales database. While the management of redundancy seems a formidable challenge, the following SQL update statement makes this change easily, and we can make the change to all affected rows: update CUSTOMER set cost_of_living = :var1 where CITY = :var2; 100,000 rows updated Using the same state_bird query as before, we see how it is simplified by removing the extra tables, as follows: select state_bird from CUSTOMER, ORDER, QUANTITY, ITEM where item_name = 'BIRDSEED' and ITEM.item_nbr = QUANTITY.item_nbr and QUANTITY.order_nbr = ORDER.order_nbr and ORDER.cust_nbr = CUSTOMER.cust_nbr; It is still necessary to join three tables, but this results in a much faster, simpler query than the original six-way table join. You can carry this concept to the point where this model is condensed into a single, highly redundant table. When creating an E/R model, it is often tempting to look at the data model from a purely logical perspective without any regard for the physical implications of the model. The designer strives to recognize and establish all of the logical relationships in the model while sometimes finding that the relationships are misleading. A relationship can be misleading when the relationship actually exists, but the application may have no need to reference this relationship. Consider the E/R model for a university shown in Figure 14.4. file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch14/460-464.html (3 of 4)4/03/2005 6:16:33
Oracle Databases on the Web:Logical Design For WebServer Applications
Figure 14.4 An example of misleading data relationships. Consider the association of the hair_color attribute to the student entity. Does a manyto-many data relationship really exist between hair_color and student? Many students have blonde hair, and blonde hair is common to many students. Why not create a many-to-many relationship between student and hair_color? The solution depends upon whether any other non-key data items exist within the hair_color entity.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch14/460-464.html (4 of 4)4/03/2005 6:16:33
Oracle Databases on the Web:Logical Design For WebServer Applications
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
If many other data items relating to hair color are present, then it is perfectly appropriate to create another entity called hair_color. But in this case, even though a many-to-many relationship exists between hair_color and student, hair_color is a standalone data attribute, so it is unnecessary to create an additional data structure. Another example is the zip_code attribute in the student entity. At first glance, it appears that a violation of Third Normal Form (that is, a transitive dependency) has occurred between city and zip_code. In other words, it appears that a zip_code is paired with the city of residence for the student. If each city has many zip_codes, while each zip_code refers only to one city, it makes sense to model this as a one-tomany data relationship (see Figure 14.5). The presence of this data relationship requires creating a separate entity called zip with attached student entities. However, this is another case where the zip entity lacks key attributes, making it impractical to create. In other words, zip_code has no associated data items. Creating a database table with only one data column would be nonsense.
Figure 14.5 An example of correct many-to-many relationships. The example in Figure 14.5 demonstrates that it is not enough to group together like items and then identify the data relationships. A practical test must be made regarding the presence of no-key attributes within an entity class. If an entity has no attributes file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch14/464-468.html (1 of 4)4/03/2005 6:16:34
Oracle Databases on the Web:Logical Design For WebServer Applications
(that is, the table has only one field), the presence of the entity is nothing more than an index to the foreign key in the member entity. It can be removed from the E/R model. This technique not only simplifies the number of entities, but it creates a better environment for a client/server architecture. More data is logically grouped together, resulting in less data access effort. Many-To-Many Data Relationships Oftentimes, a many-to-many relationship can be condensed into a more efficient structure to improve the speed of data retrieval. After all, with denormalization, less tables will need to be joined together to get the desired information. For example, Figure 14.6 shows how a many-to-many relationship can be collapsed into a more compact structure by considering the relationship between a course and a student.
Figure 14.6 An example of a university database. A student takes many courses, and each course has many students. This is a classic many-to-many relationship that would require that we define a junction table between the base entities to establish the foreign keys necessary to join the tables together. Note that the junction table is called GRADE with the following contents: • course_nbr—the primary key for the COURSE table • student_nbr—the primary key for the STUDENT table • grade—a no-key attribute to both foreign keys Next, consider the question, In what context does a grade have meaning? Stating that “The grade was A in CS-101” is insufficient, and stating that “Joe earned an A” makes no sense. Only when both the student name and the course number are associated does the grade column have meaning. Stating that “Joe earned an A in CS-101” makes sense. Recursive Data Relationships Recursive many-to-many relationships contain an object that also has a many-to-many relationship with other occurrences of the same object. These relationships are often termed Bill-of-Materials (BOM) relationships, and the graphical representation of the recursive relationship is sometimes termed a Bill-of-Materials explosion. BOM relationships are termed recursive because a single query makes many subpasses through the tables to arrive at the solution (see Figure 14.7).
Figure 14.7 An example of recursive many-to-many relationships. Bill-of-Materials relationships denote an object with a many-to-many relationship with another object in the same class. For example, a part may consist of other parts, but, at file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch14/464-468.html (2 of 4)4/03/2005 6:16:34
Oracle Databases on the Web:Logical Design For WebServer Applications
the same time, it is a component in a larger assembly. Or, a class at a university may have many prerequisites, but, at the same time, it is a prerequisite for other classes. Bill-of-Materials relationships become even more complex when we begin to create class hierarchies on top of the relationship. In Figure 14.8, you can see that the recursive relationship between parts and components has been extended to allow for different classes of parts, each with its own data elements and behaviors. Unfortunately, these types of challenges are very common. While it is true that “parts are parts,” different parts often have subtle variations—which, of course, leads to separate data columns. For example, a food-related part might have a shelf_life column, but that column does not apply to a non-food part.
Figure 14.8 Recursive many-to-many relationships with the addition of an ISA hierarchy. With an understanding of the nature of recursive relationships, the question becomes one of implementation: What is the best way to represent a recursive relationship in Oracle and navigate the structure? Listing 14.2 shows Oracle table definitions that describe the tables for our part-component example. Listing 14.2 Oracle table definitions. create table part_nbr part_name part_desc qty_on_hand
PART( number, varchar2(10), varchar2(10), number);
create table has_part is_a_part qty
COMPONENT ( number, number, number);
Look closely at the COMPONENT example. Both the has_part and is_a_part fields are foreign keys for the part_nbr field in the PART table. Therefore, the COMPONENT table contains all key values except for the qty field, which tells how many parts belong in an assembly. To understand how this works, look at the following SQL code used to display all components in a Big_Meal: select part_name from PART, COMPONENT where has_part = 'BIG MEAL' and PART.part_nbr = COMPONENT.has_part; This type of Oracle SQL query requires joining the table against itself. Unfortunately, file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch14/464-468.html (3 of 4)4/03/2005 6:16:34
Oracle Databases on the Web:Logical Design For WebServer Applications
because all items are of the same type (namely, PART), no real substitute exists for this type of data relationship, therefore the BOM relationship will most likely remain popular in Oracle.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch14/464-468.html (4 of 4)4/03/2005 6:16:34
Oracle Databases on the Web:Logical Design For WebServer Applications
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Using STAR Schema Design With WebServer One of the most popular uses for Oracle WebServer has been servicing the front-end requirements for decision support systems and data warehouses. Oracle has announced that their Oracle Express multidimensional component has now been Web enabled, but there is still a need to use Web pages for the display (and data capture) of decision support information. One common use of WebServer is to allow end users to display highly summarized Oracle data on Web pages, where they can use MS-Windows cut-and-paste commands to extract data into spreadsheets for further analysis. Because the data can be gathered from a Web page, developers do not need to write cumbersome data downloading routines, and end users can get data from anywhere in the world. The STAR schema design was first introduced by Dr. Ralph Kimball as an alternative database design for data warehouses. The name STAR comes from the design that the completed schema creates, where a large fact table resides at the center of the model surrounded by various reference tables, or points. The basic principle behind the STAR query schema is the introduction of highly redundant data for high performance. Returning to the customer-order E/R model in Figure 14.3, we see an illustration of a standard Third Normal Form database used to represent the sales of items. Because redundant information is not an issue, salient data (such as the total for an order) is computed from the items comprising the order. In this Third Normal Form database, users need a list of line items to multiply the quantity ordered by the price for all items belonging in order 123. An intermediate table called TEMP holds the result list, as shown in the following example: create table TEMP as select (QUANTITY.quantity_sold * ITEM.list_price) line_total from QUANTITY, ITEM where QUANTITY.order_nbr = 123 and QUANTITY.item_nbr = ITEM.item_nbr; select sum(line_total) from TEMP;
Note: The STATE-CITY-CUSTOMER hierarchy in Figure 14.2 is very deliberate. To be truly in the Third Normal Form, no redundant information is allowed. As such, a user’s seemingly simple query is complex to the system. For example, the SQL calculating the sum of all orders for the Western region looks very complex and involves the five-way table join, as follows: create table TEMP as select (QUANTITY.quantity_sold * ITEM.list_price) line_total From QUANTITY, ITEM, CUSTOMER, CITY, STATE file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch14/468-473.html (1 of 3)4/03/2005 6:16:35
Oracle Databases on the Web:Logical Design For WebServer Applications
where QUANTITY.item_nbr and ITEM.cust_nbr and CUSTOMER.city_name and CITY.state_name and STATE.region_name
= ITEM.item_nbr
/* join QUANTITY and ITEM */
= CUSTOMER.cust_nbr
/* join ITEM and CUSTOMER */
= CITY.city_name
/* join CUSTOMER and CITY */
= STATE.state_name
/* join CITY and STATE */
= 'WEST';
In reality, sufficient redundancy eliminates the CITY and STATE tables. The point is clear: A manager analyzing a series of complete order totals requires a huge amount of realtime computation. This process arrives at the basic tradeoff. For true freedom from redundant data, query time demands a price. In practice, the Third Normal Form database generally evolves into a STAR schema as you create a fact table to hold the quantity for each item sold (see Figure 14.9).
Figure 14.9 The STAR query E/R model. At first glance, it’s hard to believe this is the same data as the normalized database. The new fact table contains one row for each item on each order, resulting in a tremendous amount of redundant key information in the table. It should be obvious that the STAR query schema requires far more disk space than a Third Normal Form database. Also, the STAR schema is most likely a read-only database because of the widespread redundancy introduced into the model. Finally, the widespread redundancy makes updating difficult (if not impossible) for the STAR schema. Notice the dimension tables around the fact table. Some of the dimension tables contain data that is added to queries with joins. Other dimensions, such as the Region dimension, contain no data. What purpose, then, does this STAR schema achieve with huge disk space consumption and a read-only restriction? Using the STAR schema in Figure 14.9, let’s formulate SQL queries for rapid retrieval of desired information. For example, identifying the total cost for an order is simple, as seen in the following code: select sum(total_cost) order_total from FACT where FACT.order_nbr = 123; It is clear that the new structure makes the realtime query faster and simpler. Consider the result if the goal is to analyze information by aggregate values using this schema. Suppose that the manager needs the breakdown of regional sales. The data by region is not available, but the FACT table supplies the answer. Obtaining the sum of all orders for the Western region is now simple, as seen in the following code: select sum(total_cost) from FACT where region = 'WEST' The merits of the STAR schema should now be apparent, but we need to note some other ways to represent time-oriented data suitable for OLAP type systems, namely, the multidimensional database architecture, as seen in Oracle Express.
Summary file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch14/468-473.html (2 of 3)4/03/2005 6:16:35
Oracle Databases on the Web:Logical Design For WebServer Applications
It should now be clear to the reader how a proper design can be critical for good database performance. While far from being an exhaustive description of all of the relational design techniques, this chapter has focused on basic principles that will help to ensure that your WebServer database performs as quickly as possible. Once a good logical model has been created, it is critical to translate the logical model into an Oracle implementation capable of performing at optimal speed. Oracle involves many design issues, and in this chapter we’ve taken a look at how some physical design models can be used to exploit client/server performance. We have come to believe that response time is one of the most critical factors to the success of any database. Regardless of how well the system was analyzed or implemented—no matter how flashy the GUI interface—if the system fails to deliver data in a timely fashion, the project is doomed. Now that we have reviewed logical database design, let’s move on to the physical implementation of WebServer databases.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch14/468-473.html (3 of 3)4/03/2005 6:16:35
Oracle Databases on the Web:Physical Oracle Design
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
CHAPTER 15 Physical Oracle Design When creating a WebServer application, you must pay careful attention to the components that might affect system response time. These considerations include WebServer’s interaction with the Internet, Web Listener, Web Request Broker, and Oracle databases. Unfortunately, you have virtually no control over the Internet’s speed and very little control over the Web Listener and Web Request Broker. Oracle’s Web Listener and Web Request Broker have both been preoptimized by Oracle and cannot be tuned by adjusting any of their parameters. However, you can control how these components interact with your Oracle databases. More than other online applications, special consideration must be given to Oracle databases. Database transactions must be serviced efficiently to ensure that Web pages are sent to end users quickly. This chapter takes a look at the physical Oracle database design issues that can influence the performance of your WebServer applications. The topics in this chapter include the use of table replication with snapshots, referential integrity, index placement, and Oracle’s parallel facilities. The overall focus is on the use of physical database techniques for creating high-performance Oracle WebServer applications. Without an effective physical design, no amount of tuning will significantly improve performance. Hence, it is critical to any WebServer effort that you derive the optimal performance from all of your Oracle database servers.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/474-475.html (1 of 3)4/03/2005 6:16:35
Oracle Databases on the Web:Physical Oracle Design
Replication With Oracle Snapshots Oracle snapshots are used to create read-only copies of tables in other Oracle databases. Table replication is a highly effective way to avoid time-consuming and expensive cross-database joins of tables. As we know, an SQL join with a table at a remote server will be far slower than a join with a local table. The network overhead also increases as Oracle retrieves and transfers data across the network. The prudent use of replicated tables can greatly improve the response time for WebServer applications. It’s interesting to note that the general attitude about data replication has shifted dramatically in the past 10 years. In the 1980s, table replication was too expensive, both in terms of disk costs and the processing costs to update redundant tables. Also, academia believed that there was no substitute for the Third Normal Form database, and students were taught Codd’s Rules of Normalization as if the rules were physical laws of nature. Today, the practical realities of cheap disks and distributed processing have made replication an inexpensive and viable alternative to expensive crossdatabase joins. Table replication has proven to be stable and has been so successful within Oracle version 7 that Oracle version 7.3 is now introducing the concept of updatable snapshots. Snapshot is the term used by Oracle to implement their table replication strategy. However, table replication is not to be used indiscriminately, and the following several guidelines exist for using replicated tables in a WebServer application: • The replicated table should be read-only—Obviously, a table snapshot cannot be updated because the master copy of the table is on another server. • The replicated table should be relatively small—Ideally, a replicated table is small enough that the table can be dropped and re-created each night, or the refresh complete option can be used. Of course, large tables can be replicated with the refresh fast option, but this involves a complicated mechanism for holding table changes and propagating them to the replicated table. • The replicated table should be frequently accessed—It does not make sense to replicate a table if it is only referenced a few times per day, because the cost of the replication would outweigh the cost of the cross-database join. Despite any claims by Oracle to the contrary, only tables that meet the listed criteria should be placed in snapshots. In practice, snapshots are not maintenance-free, and many points of failure are possible—especially if the snapshot is created with the refresh fast option. Problems can occur writing to the SNAPSHOT_LOG table, and SQL*Net errors can cause failures of updates to transfer to the replicated tables.
Previous Table of Contents Next
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/474-475.html (2 of 3)4/03/2005 6:16:35
Oracle Databases on the Web:Physical Oracle Design
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/474-475.html (3 of 3)4/03/2005 6:16:35
Oracle Databases on the Web:Physical Oracle Design
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
How To Create Oracle Snapshots A snapshot is created on the destination system with the create snapshot SQL command, and the remote table is immediately defined and populated from the master table. After a snapshot has been created, it may be refreshed periodically. There are two types of refreshing in Oracle: complete and fast. A complete refresh can be done in several ways, but most savvy Oracle developers drop and re-create the snapshots with a Unix cron job to achieve full refreshes, especially if the table is small and easily recreated. Optionally, tables can be refreshed with only the changes made to the master table. This requires additional work on the slave database to create an Oracle refresh process (in the init.ora) and the definition of a snapshot log on the master database (see Figure 15.1).
Figure 15.1 A high-level overview of Oracle snapshots. Several steps need to be completed by the Oracle database administrator before your Oracle system is ready to use snapshots. First, the DBA needs to run catsnap.sql, which can be found in your $ORACLE_HOME/rdbms/admin directory. This script file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/475-478.html (1 of 4)4/03/2005 6:16:36
Oracle Databases on the Web:Physical Oracle Design
will populate the Oracle dictionary with the necessary system tables to manage the snapshots. The DBA also needs to run dbmssnap.sql, which can be found in the $ORACLE_HOME/rdbms/admin directory. This script creates the stored procedures that can be used to manipulate the snapshots. The following parameters must also be added to the init.ora file for each Oracle instance: • snapshot_refresh_interval=60—This sets the interval (in minutes) for the refresh process to wake up. • snapshot_refresh_processes=1—This is the number of refresh processes on the instance (the minimum is 1). • snapshot_refresh_keep_connections=FALSE—This specifies whether the database should keep remote connections after refreshing the tables. Always use FALSE. For snapshots that are small enough to be totally repopulated, it is recommended that the following steps are followed to re-create the snapshot from scratch. Note that it is possible to do a refresh complete or a refresh force rather than a cron job, but using a cron is a simple way to guarantee that the replicated table will be fully repopulated. To avoid the refresh fast option with a Unix cron, the following two steps are required: 1. Create the snapshot with the refresh complete option. 2. Alter oracle.cron to drop and re-create the snapshot. For snapshots on large tables, you may want to use the refresh fast option. To use refresh fast, the following steps are required: 1. Destination system—Create the snapshot with the refresh fast option signed on as user SYS. (Be sure to define a database link with connect to xxx identified by zzz and ensure that user xxx has select privileges against the master table.) 2. Master system—Create a snapshot log on each master table. 3. Bounce the destination system to begin the refreshes based on the interval specified in the create snapshot. Listing 15.1 shows an example of a snapshot that reads a table from an instance called fairport. Listing 15.1 Example of a snapshot with periodic refreshing. CONNECT sys/xxxx; DROP PUBLIC DATABASE LINK fairport; CREATE PUBLIC DATABASE LINK fairport CONNECT TO db_link IDENTIFIED BY db_pass USING 'fairport'; ———————————————————————————— DROP SNAPSHOT my_replicated_table; ———————————————————————————— CREATE SNAPSHOT my_replicated_table file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/475-478.html (2 of 4)4/03/2005 6:16:36
Oracle Databases on the Web:Physical Oracle Design
PCTFREE 10 PCTUSED 40 TABLESPACE ts2 STORAGE (initial 60k next 10k pctincrease 1) REFRESH FAST START WITH SYSDATE NEXT (sysdate+1) + 3/24 AS SELECT * FROM ORACLE.my_master_table@fairport; GRANT ALL ON my_replicated_table TO PUBLIC; —****************************************************** — Add the appropriate synonyms for the snapshots... —****************************************************** CONNECT /; CREATE PUBLIC SYNONYM snap$_my_replicated_table FOR ops$oracle.snap$_my_replicated_table; In Listing 15.1, you can see that the my_replicated_table table is refreshed each morning at 3:00 AM, and the read-only name snap$_my_replicated_table has been replaced with synonym my_replicated_table. Following is an example of the snapshot log syntax that needs to be run on the master database: CREATE SNAPSHOT LOG ON employee_table TABLESPACE ts2 STORAGE (initial 20k next 20k); The dbms_snapshot.refresh_all procedure can be run at any time on the destination system to refresh the snapshot tables. To force a refresh of an individual table, execute the following procedure: EXECUTE
dbms_snapshot.refresh('office','f');
Note: Any refresh errors are written to the alert.log file.
The snapshot log is a table that resides in the same database as the master table, which can be seen in the dba_tables view as a table with the name MLOG $_TABLENAME. In our example, the snapshot log would be called MLOG $_EMPLOYEE. Even with Oracle’s distributed features, it is still far faster to process a table on a local server than it is to process a remote table across SQL*Net’s distributed communication lines. As such, table replication is a very desirable technique for improving processing speeds. Several factors influence the decision about replicating tables. The foremost considerations are the size of the replicated table and the volatility of the tables. Large, highly active tables with many updates, deletes, and inserts will require a lot of system resources to replicate and keep synchronized with the master table. Smaller, less active tables would be ideal candidates for replication, because the creation and maintenance of the replicated table would not consume a high amount of system resources.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/475-478.html (3 of 4)4/03/2005 6:16:36
Oracle Databases on the Web:Physical Oracle Design
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/475-478.html (4 of 4)4/03/2005 6:16:36
Oracle Databases on the Web:Physical Oracle Design
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Oracle’s snapshot facility is relatively mature and generally works as noted in the Oracle documentation. However, the flexibility of the snapshot tool gives the developer many choices concerning how the snapshot will be created and refreshed. You can refresh a replicated table in full, recreate a snapshot at will, choose to periodically refresh a snapshot, and use database triggers to propagate changes from a master table to a snapshot table. Although the choice of techniques depends on the individual application, some general rules apply. If a replicated table is small and relatively static, it is usually easier to drop and re-create the snapshot than to use Oracle’s refresh complete option. A crontab file can be set up to invoke the dropping and re-creation of a snapshot at a predetermined time each day—completely refreshing the entire table. Another popular alternative to a snapshot is the use of Oracle’s distributed SQL to create a replicated table directly on the slave database. In the following example, the New York database creates a local table called EMP_NY, which contains New York employee information from the master employee table at corporate headquarters: create table emp_ny as select emp_nbr, emp_name, emp_phone, emp_hire_date from emp@hq where department = 'NY'; Very large replicated tables consume too much time in dropping and re-creating a snapshot or using the refresh complete option. For static tables, a snapshot log would not contain very many changes—we could direct Oracle to propagate the changes to the replicated table at frequent intervals. Let’s take a look at the different refresh intervals that can be specified for a snapshot. The following code tells Oracle to apply the snapshot log to the replicated table every seven days: create snapshot emp_snap1
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/478-482.html (1 of 3)4/03/2005 6:16:37
Oracle Databases on the Web:Physical Oracle Design
refresh fast start with sysdate next sysdate+7 as select emp_nbr, emp_name from employee@hq where department = 'NY'; The next example code shows the command for a table to be refreshed each Tuesday at 6:00 AM: create snapshot EMP_SNAP1 refresh fast start with sysdate next next_day(trunc(sysdate),'tuesday')+6/24 as select emp_nbr, emp_name from employee@hq where department = 'NY'; For very static tables, you can specify refreshes to run quarterly. The following example refreshes a table completely on the first Tuesday of each quarter: create snapshot emp_snap1 refresh complete start with sysdate next next_day(add_months(trunc(sysdate,'q'),3),'tuesday') as select emp_nbr, emp_name from employee@hq where department = 'NY'; For dynamic tables that require refreshing daily, you can specify that the table is refreshed at a particular time each day. The following code refreshes a table every day, at 11:00 AM: create snapshot emp_snap1 refresh fast start with sysdate next sysdate+11/24 as select emp_nbr, emp_name from employee@hq where department = 'NY'; In addition to using the time range specified in the create snapshot syntax, you can also use Oracle stored procedures to get the same results. If you run the dbmssnap.sql script, you can refresh a snapshot by issuing the following command: execute dbms_snapshot.refresh('employee','c'); execute dbms_snapshot.refresh('employee','f'); execute dbms_snapshot.refresh('employee','?');
/* complete refresh */ /* forced refresh */ /* fast refresh */
Using Triggers To Update Snapshots What about replicated tables that require instantaneous propagation? Oracle version 7.3 offers updatable snapshots. Fortunately, users of previous releases of Oracle can also update snapshots by using database triggers to simulate the realtime propagation of changes from a master table to replicated tables. In the following example, an update trigger has been placed on the employee tables, and relevant changes will be propagated to the New York branch: Create trigger add_employee after insert on employee As If :dept = 'NY' then (insert into employee@NY values(:parm1, :parm2,:parm3); ); Your next question might be, What can we do about rows deleted from the employee table? Using the file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/478-482.html (2 of 3)4/03/2005 6:16:37
Oracle Databases on the Web:Physical Oracle Design
same technique, a delete trigger can be placed on the employee table to remove rows from the replicated tables: create trigger delete_employee after delete on employee as if :dept = 'NY' then (delete from employee@NY where emp_nbr = :employee_parm ); Using Snapshots To Propagate Subsets Of Master Tables As we have seen, snapshot replication is very handy for taking a master table and copying it to a remote location. But, what if we only want to replicate a portion of a table? Yes, Oracle provides a method for excluding certain rows and columns from the replicated table. For example, let’s assume that you are replicating a central employee table for use by your New York branch. However, you only want to replicate employee records for those who work in the New York branch, and you want to exclude confidential columns, such as the employees’ salaries. The snapshot would appear as follows: create snapshot emp_ny refresh fast start with sysdate next next_day(trunc(sysdate),'tuesday')+6/24 as select emp_nbr, emp_name, emp_phone, emp_hire_date from emp@hq where department = 'NY';
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/478-482.html (3 of 3)4/03/2005 6:16:37
Oracle Databases on the Web:Physical Oracle Design
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Using Referential Integrity With Oracle Referential Integrity (RI) rules ensure that one-to-many and many-to-many relationships are enforced within the relational schema. In addition, valid values can also be enforced with constraints. Constraints are especially important to WebServer applications, because WebServer allows constraint checking to take place at the database server, thereby relieving the Web client of the burden of checking constraints. Several types of constraints can be applied to Oracle tables to enforce referential integrity, including: • Check Constraint—This constraint validates incoming columns at row insert time. For example, rather than having an application verify that all occurrences of region are North, South, East, or West, a check constraint can be added to the table definition to ensure the validity of the region column. • Not Null Constraint—This constraint is used to specify that a column may never contain a NULL value. This is enforced at SQL insert and update time. • Primary Key Constraint—This constraint is used to identify the primary key for a table. This operation requires that the primary columns are unique, and Oracle will create a unique index on the target primary key. • References Constraint—This is the foreign-key constraint as implemented by Oracle. A references constraint is only applied at SQL insert and delete times. For example, assume a one-to-many relationship between the EMPLOYEE and DEPENDENT tables—each employee may have many dependents, yet
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/482-484.html (1 of 3)4/03/2005 6:16:37
Oracle Databases on the Web:Physical Oracle Design
each dependent belongs to only one employee. The references constraint tells Oracle at insert time that the value in DEPENDENT.emp_num must match the EMPLOYEE.emp_num in the employee row, thereby ensuring that a valid employee exists before the dependent row is added. At SQL delete time, the references constraint can be used to ensure that an employee is not deleted if rows still exist in the DEPENDENT table. • Unique Constraint—This constraint is used to ensure that all column values within a table never contain a duplicate entry. Notice the distinction between unique and primary key. While both of these constraints create a unique index, a table may contain only one primary key constraint column—but it may have many unique constraints on other columns. Referential integrity usually needs to be double coded: once for the database and again within the application. For example, in a multipart SQL*Form, you may not become aware of an RI violation until you are many pages into the form and your form attempts to commit. In WebServer applications, you do not have the luxury of making a lot of queries against the database, and you need to be careful to keep the Oracle transactions as few as possible. Referential integrity maintains business rules. Relational systems allow control of business rules with constraints, and RI rules form the backbone of relational tables. For example, RI ensures that a row in the CUSTOMER table is not deleted if the ORDER table contains dependents for that employee (see Figure 15.2).
Figure 15.2 An example of referential integrity. It is clear that enforcing this business rule in our new distributed environment is a real challenge. While it is relatively simple to tell an Oracle system not to delete a row from its CUSTOMER table if rows for that employee exist in the ORDER table, it is not simple to enforce this rule when the CUSTOMER table resides in a Sybase database and the ORDER table resides within Oracle. The solution is to remove the database RI rules from each database, remembering to manually replicate the RI rules using procedural code within the application. This essentially creates your own customized RI within the application.
Previous Table of Contents Next
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/482-484.html (2 of 3)4/03/2005 6:16:37
Oracle Databases on the Web:Physical Oracle Design
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/482-484.html (3 of 3)4/03/2005 6:16:37
Oracle Databases on the Web:Physical Oracle Design
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Indexes And Oracle Performance In Oracle, an index is used to speed up the time required to access table information. Internally, Oracle indexes are B-tree data structures, in which each tree node may contain many sets of key values and row IDs. In general, Oracle indexes exist for the purpose of preventing full-table scans. Fulltable scans have two problems, the most important being the time lost in servicing a request as each and every row of a table is read into Oracle’s buffer pool. The second problem associated with full-table scans is that they cause performance degradation at the system level. All other tasks on the system may have to incur additional I/O, because the buffer block held by competing tasks will have been flushed by the fulltable scan. As blocks are flushed from the buffer pool, other tasks incur additional I/Os to reread information that would have remained in the buffer pool if the full-table scan had not been invoked. In general, just about any Oracle table will benefit from the use of indexes. The only exception to this rule would be a very small table that can be read in less than two physical I/Os. Two physical I/Os are used as the guideline because Oracle needs to perform at least one I/O to access the root node of the index tree and another I/O to retrieve the requested data. For example, assume that a lookup table contains rows of 25 bytes each, and you have configured Oracle to use 4 K block sizes. Because each data block would hold about 150 rows, using an index for up to 300 rows would not make the processing any faster than a full-table scan. If you plan to use the Oracle parallel query facility, all tables specified in the SQL query must be optimized for a full-table scan. If an index exists, the cost-based optimizer must be used with a hint to invalidate the index in order to use parallel query. For the rule-based optimizer, indexes can be turned off by using an Oracle
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/484-486.html (1 of 2)4/03/2005 6:16:38
Oracle Databases on the Web:Physical Oracle Design
function in the where clause. One important concept in indexing is the selectivity, or the uniqueness, of the values in a column. To be effective, an index column must have many unique values. Columns that have only a few values (e.g., sex = m/f, status = y/n) would not be good candidates for indexing. Similar to the index itself, the sparse distribution of values would be less efficient than a full-table scan. To see the selectivity for a column, compare the total number of rows in the table with the number of distinct values for the column. For example: select count(*) from EMPLOYEE; select distinct status from EMPLOYEE; Another concept used in indexing is called distribution, which refers to the frequency that each unique value is distributed within the database. For example, we may have a state_abbreviation column that contains 1 of 50 possible values. This would be acceptable to use as an index column, provided that the state abbreviations are uniformly distributed across the rows. However, if 90 percent of the values are for New York, then the index will not be very effective. Oracle has addressed the index data distribution issue with the analyze table command. When using Oracle’s costbased SQL optimizer, analyze table will look at both the selectivity and distribution of the column values. If they are found to be out-of-bounds, Oracle may decide not to use the index. Oracle recommends the following guidelines when considering whether to use an index on a column: • Columns frequently referenced in SQL where clauses are good candidates for an index. • Columns used to join tables (primary and foreign keys) should be indexed. • Do not use a B-tree index on columns with poor selectivity. Any column with less than 10 percent of unique values should be indexed as a bitmap index. • Frequently modified columns are not good candidates for indexing because excessive processing is necessary to maintain the structure of the index tree. • Do not index columns used in SQL where clauses using Oracle functions or operators. For example, an index for last_name will not be effective if it is referred to in the SQL as upper(last_name). • When using referential integrity, always create an index on the foreign key.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/484-486.html (2 of 2)4/03/2005 6:16:38
Oracle Databases on the Web:Physical Oracle Design
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Tuning Queries With Indexes As a general rule, indexes will always increase the performance of a database query. In situations where a query intends to sweep a table in the same sequence that the rows are physically stored, the indexes in some tables may actually hinder performance. For Oracle, indexes are recommended for two reasons: to speed the retrieval of a small set of rows from a table and to presort result sets so that the SQL order by clause does not cause an internal sort. In order to use an index, the SQL optimizer must recognize that the column has a valid value for index use. This is called a sargeable predicate, and it’s used to determine the index access. Listing 15.2 shows some valid predicates, and Listing 15.3 shows invalid predicates. Listing 15.2 Viewing valid predicates. select * from EMPLOYEE where emp_no = 123; select * from EMPLOYEE where dept_no = 10; Listing 15.3 Viewing invalid predicates. select * from EMPLOYEE where emp_no = "123"; select * from EMPLOYEE where salary * 2 < 50000; select * from EMPLOYEE where dept_no != 10; Whenever a transformation to a field value takes place, the Oracle database will not be
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/486-489.html (1 of 4)4/03/2005 6:16:39
Oracle Databases on the Web:Physical Oracle Design
able to use the index for that column. Some databases, such as DB2, will recognize a linear search and invoke a sequential prefetch to look ahead, reading the next data block while the previous data block is being fetched by the application. As a general rule, an SQL query that retrieves more than 15 percent of the table rows in a table will run faster if the optimizer chooses a full-table scan rather than an index. For example, assume that a student table has 1,000 rows, representing 900 undergraduate students and 100 graduate students. A nonunique index has been built on the student_level field that indicates underdgrad or grad. The same query will benefit from different access methods, depending upon the value of the literal in the where clause. The following query will retrieve 90 percent of the rows in the table and will run faster with a full-table scan rather than an index: select * from STUDENT where student_level = 'undergrad'; This next query will only access 10 percent of the table rows and will run faster by using the index on the student_level field: select * from STUDENT where student_level = 'grad'; Unfortunately, the Oracle database cannot predict in advance the number of rows that will be returned from a query. Many SQL optimizers will invoke an index access even though it may not always be the fastest access method. To remedy this problem, some dialects of SQL allow the user to control the index access. This is a gross violation of the declarative nature of theoretical SQL, in which the user does not control access paths. But, in practice, these extensions can improve performance. Oracle, for example, allows the concatenation of a null string to the field name in the where clause to suppress index access. The previous query could be rewritten in Oracle SQL to bypass the student_level index, as follows: select * from STUDENT where student_level||'' = 'undergrad'; The concatenation (||) of a null string to the field tells the Oracle SQL optimizer to bypass index processing for this field, instead of invoking a faster-running full-table scan. This a very important point. While SQL optimizers are becoming more intelligent about their databases, they still cannot understand the structure of the data and will not always choose the best access path. Concatenated Indexes A concatenated index is an index created on multiple columns. This type of index can greatly speed up queries where all of the index columns are specified in the queries’ SQL where clauses. For example, assume the following index on the STUDENT table: create index idx1 on STUDENT file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/486-489.html (2 of 4)4/03/2005 6:16:39
Oracle Databases on the Web:Physical Oracle Design
(student_level, major, last_name) ascending; The following concatenated index could be used to speed up queries that reference both student_level and major in the where clause: select student_last_name from STUDENT where student_level = 'undergrad' and major = 'computer science'; However, some queries using only major or student_level will not be able to use this concatenated index. In the following example, only the major field is referenced in the query, and a concatenated index cannot be used to service the query: select * from STUDENT where major = 'computer science'; In the following example, we see that student_level is the high-order index key, and the index will be used because student_level is the high-order index key: select last_name from STUDENT where student_level = 'plebe' order by last_name; Because student_level is the first item in the index, the leading portion of the index can be read, and the SQL optimizer will invoke an index scan. Why have we chosen to add the last_name to the index, even though it is not referenced in the where clause? Because Oracle will be able to service the request by reading only the index, and the rows of the STUDENT table will never be accessed. Also, because the order by clause asks to sort by last_name, Oracle will not need to perform a sort on this data. The not (!) operator will cause an index to be bypassed, and the query “show all undergrads who are not computer science majors” will cause a full-table scan: select * from STUDENT where student_level = 'undergrad' and major != 'computer science'; Here, the not condition isn’t a sargeable predicate and will cause a full-table scan.
Previous Table of Contents Next
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/486-489.html (3 of 4)4/03/2005 6:16:39
Oracle Databases on the Web:Physical Oracle Design
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/486-489.html (4 of 4)4/03/2005 6:16:39
Oracle Databases on the Web:Physical Oracle Design
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Oracle Locking While most commercial database products provide mechanisms for locking and concurrency control, new issues emerge when using a relational database such as Oracle (see Figure 15.3). This problem is especially prevalent when a single Oracle task updates multiple remote servers, which is becoming increasingly common with distributed Oracle systems. The real nightmare begins when the remote servers are of differing architectures—for example, a distributed update to a relational and a network database. In these cases, the concurrency control is generally turned off for each database and is provided for inside the application program. After all, neither database can be expected to manage the internals of the other database.
Figure 15.3 An overview of Oracle locking. In addition to the technical issues, the popularity of client/server interfaces has also changed how concurrency is handled. Many client/server systems disable their Oracle database locking and rely upon procedural tricks to maintain data integrity at the server level. Oracle is one of these products, and we’ll discuss how to avoid contention by disabling Oracle locks.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/489-492.html (1 of 4)4/03/2005 6:16:39
Oracle Databases on the Web:Physical Oracle Design
Most programmers do not realize that database deadlocks occur frequently within database indexes. It’s important to note that a select of a single row from a database may cause more than one lock entry to be placed in the storage pool. When one row is locked, all affected index rows will also be locked. In other words, the individual row receives a lock, as well as each index node that contains the value for that row. If the “last” entry in a sorted index is retrieved, the database will lock all index nodes that reference the indexed value (in case the user changes that value). Many indexing schemes always carry the high-order key in multiple index nodes, so an entire branch of the index tree can be locked—all the way up to the root node of the index. While each database’s indexing scheme is different, some relational database vendors recommend that tables with ascending keys be loaded in descending order, so that the rows are loaded from Z to A on an alphabetic key field. Oracle recommends dropping indexes before large updates and re-creating the indexes after the rows have been loaded into the table. When an update or delete is issued against a row that participates in an index, the database will attempt an exclusive lock on the row, which requires the task to check for any shared locks held against the row as well as any index nodes that will be affected. Many indexing algorithms allow for the index tree to dynamically change shape, spawning new levels as items are added and condensing levels as items are deleted. For any table of consequential size, indexes are recommended to improve performance. Of course, an index requires additional disk space—a table with an index on each column will have indexes that consume more space than the table. Oracle will also update the indexes at runtime, as columns are deleted, added, or modified. This index updating can cause considerable performance degradation. For example, adding a row to the end of a table will cause Oracle to adjust the high-key value for each node in the table. One guideline for determining when to use an index involves examination of the SQL issued against a table. In general, the SQL can be collected, and each value supplied in each SQL where clause could be a candidate for inclusion in an index. Another common approach for determining where to create indexes is to run an explain plan for all SQL and carefully look for any full-table scans. The Oracle optimizers operate in such a fashion that Oracle will sometimes perform a full-table scan, even if an index has been defined for the table. This occurs most commonly when issuing complex n-way joins. If you are using rule-based optimization in Oracle, the structure of the SQL statement can be adjusted to force the use of an existing index. For Oracle’s cost-based optimizer, adding hints to the structure will ensure that all indexes are used. Keep in mind that indexes do much more than speed up an individual query. When full-table scans are performed on a large Oracle table, the buffer pool begins to page out blocks from other queries. This causes additional I/O for the entire database and results in poor performance for all queries—not just the offending full-table scan. Indexes are never a good idea for long descriptive columns. A column called employee_description would be a poor choice for an index because of its length and the inconsistency of the data within the column. If this column was 300 bytes, Oracle file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/489-492.html (2 of 4)4/03/2005 6:16:39
Oracle Databases on the Web:Physical Oracle Design
would be forced to do a huge amount of processing whenever the column is altered. Also, a field such as employee description would usually be referenced in SQL by using Oracle extensions, such as substr, like, and upper. Remember, these Oracle extensions invalidate the index. Suppose that an index has been created on employee_last_name. The following query would use the index: select status from EMPLOYEE where employee_last_name = 'burleson'; The following queries would bypass the index, causing a full-table scan: select status from EMPLOYEE where employee_last_name = lower('burleson'); select status from EMPLOYEE where employee_last_name like 'burl%'; Unlike other relational databases, Oracle cannot physically load a table in key order. Consequently, we can never guarantee that the rows in the table will be in any particular physical order. The use of an index can help whenever the SQL order by clause is used. For example, even if there are no complex where conditions, the presence of a where clause will assist the performance of the query. Consider the following SQL: select employee_last_name, employee_first_name from EMPLOYEE order by employee_last_name, employee_first_name; Building a multi-valued index on employee_last_name and employee_first_name will alleviate the need for an internal data sort. You can significantly improve the performance of the query by using the following SQL: create index emp_name on EMPLOYEE (employee_last_name, employee_first_name) ascending;
Previous Table of Contents Next
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/489-492.html (3 of 4)4/03/2005 6:16:39
Oracle Databases on the Web:Physical Oracle Design
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/489-492.html (4 of 4)4/03/2005 6:16:39
Oracle Databases on the Web:Physical Oracle Design
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Oracle Constraints And Indexes In Oracle, some constraints will create an index on your behalf. For example, creating a primary key constraint on the EMPLOYEE table for the emp_id will create an index on the field, and it is not necessary to manually build an index (see Listing 15.4). Listing 15.4 Creating a primary key constraint. create table EMPLOYEE ( emp_nbr number constraint emp_ukey primary key (emp_nbr) using index pctfree 10 initrans 2 maxtrans 255 tablespace ts1 storage ( initial 256000 next 102400 minextents 1 maxextents 121 pctincrease 1 ), dept_name char(10) constraint dept_fk references DEPT on delete cascade, organization_name char(20) constraint org_fk references ORG on delete restrict, region_name
char(2)
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/493-495.html (1 of 3)4/03/2005 6:16:40
Oracle Databases on the Web:Physical Oracle Design
constraint state_check check (region_name in ('north', south', 'east', 'west')) ); Notice that you should always specify the location clause when declaring constraints. In the previous example, had the emp_ukey constraint been defined without the storage clause, the index would have been placed in whatever tablespace is specified by the table owner’s default tablespace, with whatever default storage parameters are in effect for that tablespace. Listing 15.4 shows some good examples of Oracle constraints. The first constraint is on the emp_nbr column—the primary key. When you use Oracle’s RI to specify a primary key, Oracle automatically builds a unique index on the column to ensure that no duplicate values are entered. The second constraint is on the dept_name column of the DEPT table. This constraint tells Oracle that it may not remove a department row if there are existing employee rows that reference that department. The on delete cascade tells Oracle that when the department row is deleted, all employee rows that reference that department will also be deleted. The next RI constraint on organization_name ensures that no organization is deleted if employees are participating in that organization. on delete restrict tells Oracle not to delete an organization row if any employee rows still reference the organization. Only after each and every employee has been set to another organization can the row be deleted from the organization table. The last RI constraint is called a check constraint. In a check constraint, Oracle verifies that a column is one of the valid values before inserting a row, but it will not create an index on the column. Using Multicolumn Indexes With Oracle When an SQL request is commonly issued using multiple columns, a concatenated or multicolumn index can be used to improve performance. Oracle supports the use of multivalued indexes, but there are some noteworthy limitations. Unlike other relational databases, Oracle requires that all columns in the index are sorted in the same order, either ascending or descending. For example, if we needed to index on employee_last_name ascending, followed immediately by gross_pay descending, we would not be able to use a multivalued index. Sometimes, two columns that have poor selectivity (i.e., columns having few unique values) can be combined into an index that has better selectivity. For example, we could combine a status field that has three values (good, neutral, and bad) with another column such as state_name (only 50 unique values), thereby creating a multivalued index that has far better selectivity than each column would have if indexed separately. Also, in Oracle version 7.3, bitmapped indexes can be defined for columns with poor selectivity, thereby improving SQL through put. Another reason for creating concatenated indexes is to speed the execution of queries that reference all of the values in an index. For example, consider the following query: select
employee_last_name, employee_status, employee_zip_code from EMPLOYEE order by employee_last_name; Now, you can create an index as follows: create index last_status_zip file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/493-495.html (2 of 3)4/03/2005 6:16:40
Oracle Databases on the Web:Physical Oracle Design
on EMPLOYEE (employee_last_name, employee_status, employee_zip_code) ascending; If this query were to be issued against the employee table, Oracle would never need to access any rows in the base table! All of the key values are contained in the index, and the high-order key (employee_last_name) is in the order by clause. Oracle can scan the index, retrieving the data without ever touching the base table. With the assistance of this feature, the savvy Oracle developer can add columns to the end of the concatenated index so that the base table is never touched. For example, if the previous query also returned the value of the employee_address column, this column could be added to the concatenated index, dramatically improving performance. In summary, the following guidelines apply when creating a concatenated index: • Use a composite index whenever two or more values are used in the SQL where the clause and the operators are joined by and. • Place the columns in the where clause in the same order as in the index, with data items added at the end of the index.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/493-495.html (3 of 3)4/03/2005 6:16:40
Oracle Databases on the Web:Physical Oracle Design
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
How Oracle Chooses Indexes It is interesting to note that the fastest execution for an individual task may not always be the best choice. For example, consider the following query against an employee table: select employee_name from EMPLOYEE where credit_rating = 'poor' and amount_due > 1000 and state = 'iowa' and job_description like lower('%computer%'); Here, you can see a query where a full-table scan would be the most efficient processing method. Because of the complex conditions and the use of Oracle extensions in the SQL, it might be faster to perform a full-table scan. However, the fast execution of this task may be done at the expense of other tasks on the system as the buffer pool becomes flushed. In general, the type of optimizer will determine how indexes are used. As we know, the Oracle optimizer can run as either rule-based or cost-based. As a general rule,
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/495-498.html (1 of 3)4/03/2005 6:16:41
Oracle Databases on the Web:Physical Oracle Design
Oracle is intelligent enough to use an index if it exists, but there are exceptions to this rule. The most notable exception is the n-way join with a complex where clause. The rule-based optimizer will get confused and invoke a full-table scan on at least one of the tables, even if the appropriate foreign key indexes exist for all of the tables. The only remedy to this problem is to use the cost-based optimizer, which involves analyzing statistics for each table. You should also remember that Oracle will only use an index when the index column is specified in its “pure” form. The use of the substr, upper, lower, and other functions will invalidate an index. However, there are a few tricks to help you get around this obstacle. Consider the following two equivalent SQL queries: select * from EMPLOYEE where total_purchases/10 > 5000; select * from EMPLOYEE where total_purchases > 5000*10; The second query, by virtue of the fact that it does not alter the index column, would be able to use an index on the total_purchases column.
Parallelism And Client/Server The widespread acceptance of distributed processing and multitasking operating systems has heralded a new mode of designing and implementing business systems. Instead of the traditional linear design of systems, tomorrow’s system will incorporate massively parallel processing. The result? Many tasks may be concurrently assigned to service a database request. Indeed, the entire definition of data processing is changing. The corporate data resource has been expanded to include all sources of information, not just databases. Corporate information lies within email, scheduling programs, and many other nontraditional sources. Many companies are collecting this information without fully exploiting its value, and multiprocessing is an ideal technique for searching these huge amounts of free-form corporate information. Multitasking And Multithreading WebServer Processes Before tackling this subject, a distinction needs to be made between multitasking and multiprocessing. Multitasking refers to the ability of a software package to manage multiple concurrent processes, thereby allowing simultaneous processing. Although OS/2 and Windows NT are good examples of this technology, multitasking can be found within all midrange and mainframe databases. Multiprocessing refers to the use of multiple CPUs within a distributed environment where a master program directs parallel operations against numerous machines. Two levels of multiprocessing are possible. The first is the hardware level, where arrays of CPUs are offered. The second is the software level, where a single CPU can be partitioned into separate logical processors. The Prism software on the IBM mainframe environment is an example of multiprocessing technology.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/495-498.html (2 of 3)4/03/2005 6:16:41
Oracle Databases on the Web:Physical Oracle Design
In any case, programming for multiprocessors is quite different from linear programming techniques. Multiprocessing programming falls into two areas: data parallel programming and control parallel programming. Data parallel programming partitions the data into discrete pieces, running the same program in parallel against each piece. Control parallel programming identifies independent functions that are simultaneously solved by independent CPUs (see Figure 15.4).
Figure 15.4 An example of a parallel query. One of the greatest problems with implementing parallel processing systems is the identification of parallelism. Parallelism refers to the ability of a computer system to perform processing on many data sources in the same instant. Traditionally, database applications were linear in nature. Today’s systems have many opportunities for parallel processing. Parallelism is especially important for processes such as scientific applications that benefit from having hundreds—or even thousands—of processors working together to solve a problem. The same concept of parallelism applies to very large databases. If a query can be split into subqueries where each subquery is assigned to a processor, the response time for the query can reduce by a factor of thousands (see Figure 15.5).
Figure 15.5 The performance benefits of adding processors.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/495-498.html (3 of 3)4/03/2005 6:16:41
Oracle Databases on the Web:Physical Oracle Design
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
A review of the past 30 years makes it clear that tremendous improvements have been made in the speed of processors. At the same time, the prices of processors have continued to decline. However, this trend cannot continue forever. The physical nature of silicon processors has been pushed to its limit and is now reaching a diminishing point of return. In order to continue to enjoy increases in performance, either silicon needs to be replaced as a medium or new ways need to be devised to exploit parallelism in processing. Parallelism is an issue of scale. Where a linear process may solve a problem in 1 hour, a parallel system with 60 processors should be able to solve the problem in 1 minute, as demonstrated in Figure 15.5. In some instances, this statement would be analogous to the statement that one woman takes nine months to have a baby, so nine women should be able to produce a baby in one month. Speed can only be improved in situations where parallel processing is appropriate, which excludes traditional linear systems where one process may not begin until the preceding one ends. Other facets to parallel processing can be extremely valuable. A query against a very large database can be dramatically improved if the data is partitioned. For example, if a query against a text database takes one minute to scan a terabyte, then partitioning the data and processing into 60 pieces would result in a retrieval time of one second. Another key issue is the balancing of the CPU processing with the I/O processing. In a traditional data processing environment, the systems are not computationally intensive, and most of the elapsed time is spent waiting on I/O. However, this does not automatically exclude business systems from taking advantage of multiprocessing.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/498-502.html (1 of 4)4/03/2005 6:16:41
Oracle Databases on the Web:Physical Oracle Design
A continuum of processing architecture exists for parallel processing. On one end of the spectrum you find a few powerful CPUs loosely connected; on the other end is a large number of small, tightly coupled processors. Parallelism can be easily identified in a distributed database environment. For the database administrator, routine maintenance tasks such as export/import operations can be run in parallel, reducing the overall time required for system maintenance. In an open systems environment, parallelism may be simulated easily by using a remote mount facility. With a remote mount, a data file may be addressed directly from another processor, even though the data file physically resides on another machine. SMP Vs. MPP Processing SMP, or symmetrical multiprocessing, describes an architecture where many CPUs share a common memory area and I/O buffer. This type of architecture is not scaleable, as additional processors must compete for the shared memory and I/O resources. On the other hand, massively parallel processors (MPP) describes an architecture where many independent processors share nothing, operating via a common I/O bus. An MPP system can add processors without impeding performance, and performance will actually increase as processors are added.
Using Oracle’s Parallel Query With Oracle version 7.2, some powerful new features have been introduced to allow parallel processes to be used against the Oracle database. These features include: • Parallel create table as select • Parallel query • Parallel index building Please note that the new features of Oracle versions 7.2 and 7.3 will not be activated unless the following init.ora parameter has been used: COMPATIBILITY=7.3.0.0.0 Also, note that it is not necessary to have parallel processors (SMP or MPP) in order to use and benefit from parallel processing. Even on the same processor, multiple processes can be used to speed up queries. Oracle parallel query options can be used with any SQL select statements—the only restriction being that the query performs a full-table scan on the target table. Parallel queries are most useful in distributed databases where a single logical table has been partitioned into smaller tables at each remote node (see Figure 15.6). For example, an employee table ordered by employee name may be partitioned into an employee table at each remote database, such that you have a phoenix_employee, a los_angeles_employee, and so on. This approach is very common with distributed databases, where local autonomy of processing is important. However, what about the needs of those in corporate headquarters? How can they query all of these remote file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/498-502.html (2 of 4)4/03/2005 6:16:41
Oracle Databases on the Web:Physical Oracle Design
tables as a single unit and treat the logical employee table as a single entity?
Figure 15.6 An example of Oracle’s parallel query. While this splitting of a table according to a key value violates normalization theory, it can dramatically improve performance for individual queries. For large queries that span many logical tables, the isolated tables can be easily reassembled using Oracle’s parallel query facility, as follows: create view all_employee as select * from phoenix_employee@phoenix UNION ALL select * from los_angeles_employee@los_angeles UNION ALL select * from rochester_employee@rochester;
Note: The @ references refer to SQL*Net service names for the remote hosts.
We can now query the all_employee view as if it were a single database table, and Oracle parallel query will automatically recognize the union all parameter, firing off simultaneous queries against each of the three base tables. It’s important to note that the distributed database manager will direct each query to be processed at the remote location, while the query manager waits until each remote node has returned its result set. The following query will assemble the requested data from the three tables in parallel, with each query optimized separately: select employee_name from ALL_EMPLOYEE where total_purchases > 5000; The result set from each subquery is then merged by the query manager.
Summary Now that you understand the logical and physical database design issues that influence WebServer’s performance, let’s take a look at the performance and tuning issues that arise when creating a WebServer database. Let’s also look at how the tuning of SQL can help WebServer’s performance. We’ll do just that, in upcoming chapters.
Previous Table of Contents Next
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/498-502.html (3 of 4)4/03/2005 6:16:41
Oracle Databases on the Web:Physical Oracle Design
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch15/498-502.html (4 of 4)4/03/2005 6:16:41
Oracle Databases on the Web:Database Performance And Tuning
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
CHAPTER 16 Database Performance And Tuning There are several factors that influence the performance of a WebServer application. While most of the factors are within the control of Oracle developers, some issues, such as Internet communications, are beyond the control of the Oracle developer. Consequently, we can only address performance and tuning of WebServer applications from the time a URL request is intercepted by the Web Listener until the completed request has been serviced and returned to the client. During this period, the following steps occur: 1. The request is intercepted by the Web Listener. 2. The request is forwarded to the CGI or the WRB. 3. The request is handed to Oracle. 4. Oracle services the request and passes the data back to the CGI or WRB. 5. The Web document is prepared and sent through the Web Listener to the requesting client. Oracle WebServer achieves acceptable performance through a variety of mechanisms. The following sections discuss some of the mechanisms affecting WebServer’s performance.
WebServer Performance Issues Response time with the Oracle WebServer is a function of the interaction between numerous components. The following components are listed in order of their impact on WebServer performance and speed:
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/503-505.html (1 of 3)4/03/2005 6:16:42
Oracle Databases on the Web:Database Performance And Tuning
1. 2. 3. 4. 5.
The Internet (data transmission across the Internet) The Oracle database (servicing data requests) The Web Listener (spawning Oracle requests) The Web Request Broker (building HTML pages) The PL/SQL agent (loading and executing Oracle stored procedures)
We have no control over the speed of the Internet, but we do have some control over the Oracle components. Let’s take a look at some of the performance and tuning issues involved with the last two components. The Web Request Broker The Web Request Broker accepts connections from the Web Listener. These requests are in the form of URLs. When the WRB first receives a request, it interrogates the URL to determine the type of object being requested. The request could be for an Oracle stored procedure, a Java routine, or any routine that has been defined with a socket. The determination of the type of object being requested is a function of the pathname in the URL. The internal meaning of pathnames is governed by the WebServer configuration. For example, the WebServer may be configured so that URL requests beginning with /oraproc are passed to the PL/SQL agent and URL requests beginning with /java are passed to the Java interpreter. The PL/SQL Agent Interacting with a PL/SQL agent is generally much easier than interacting with Oracle using LiveHTML or Java. In addition, the PL/SQL agent is much faster than it was in WebServer version 1.0. This is due to a change in the architecture, whereby each instance of the PL/SQL agent stays connected to Oracle between database requests. Continuous connection does not mean that a run-unit connection is maintained with Oracle. Rather, it means that a communication connection to Oracle has been established, but no database connection has been made via SQL*Net. As you know, when someone establishes a connection to SQL*Plus, you can see the connection by selecting the V$SESSION view within Oracle. This is not the case with WebServer, because the PL/SQL agent only connects to Oracle during the servicing of the request. The servicing of a PL/SQL request consists of the following steps: 1. Retrieving the stored procedure from Oracle. 2. Executing the stored procedure. 3. Performing the specified database access. Because each HTTP request initiates a new SQL*Net session, Oracle is technically logging off and reestablishing an SQL*Net session each time a URL request is made. However, this process happens quickly because the Oracle server connection is maintained between URL requests.
Previous Table of Contents Next
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/503-505.html (2 of 3)4/03/2005 6:16:42
Oracle Databases on the Web:Database Performance And Tuning
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/503-505.html (3 of 3)4/03/2005 6:16:42
Oracle Databases on the Web:Database Performance And Tuning
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Oracle Stored Procedures As objects such as stored procedures and triggers become more popular, more application code will move away from external programs and into the database engine. Oracle has been encouraging this approach in anticipation of the object-oriented features of Oracle8. We have even more reasons for using stored procedures with WebServer applications because stored procedures are the method used for all PL/SQL interfaces with Oracle. However, Oracle DBAs must be aware of the increased memory demands associated with stored procedures. DBAs must plan carefully for the increased memory requirements when processing logic within databases. Today, most Oracle databases have only a small amount of code in stored procedures—but this is rapidly changing. WebServer requirements aside, many compelling benefits can be derived by placing all Oracle SQL inside stored procedures. These benefits include: • Better performance—Stored procedures are loaded once into the SGA and remain there unless they become paged out. Subsequent executions of the stored procedure are far faster than external code. • Coupling of data with behavior—Relational tables can be coupled with the behaviors associated with them by using naming conventions. For example, if all behaviors associated with the EMPLOYEE table are prefixed with the table name (i.e., EMPLOYEE.hire, EMPLOYEE.give_raise), then the data dictionary can be queried to list all behaviors associated with a table (for instance, select * from dba_objects where owner = ‘EMPLOYEE’), and
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/505-507.html (1 of 3)4/03/2005 6:16:43
Oracle Databases on the Web:Database Performance And Tuning
code can be readily identified and reused. • Isolation of code—Because all SQL is moved out of the external programs and into stored procedures, the application programs are nothing more than calls to stored procedures. As such, it becomes very simple to swap out one database and swap in another. One of the foremost reasons why stored procedures and triggers function faster than traditional code is related to Oracle System Global Area (SGA). After a procedure has been loaded into the SGA, it will remain in the library cache until it’s paged out of memory. Items are paged out of memory based on a least-recently-used algorithm. Once loaded into the RAM memory of the shared pool, the procedure will execute very quickly. The trick is to prevent pool-thrashing during the period when many procedures are competing for a limited amount of library cache within the shared pool memory. Thrashing is the condition where stored procedures are flushed out of the library cache to make room for other stored procedures. When tuning Oracle, two init.ora parameters emerge as more important than all of the other parameters combined. These are the db_block_buffers and the shared_pool_size parameters. These two parameters define the size of the in-memory region that Oracle consumes on startup and determines the amount of storage available to cache data blocks, SQL, and stored procedures. Oracle also provides a construct called a package. Essentially, a package is a collection of functions and stored procedures that can be organized in a variety of ways. For example, functions and stored procedures for employees can be logically grouped together in an employee package, as follows: create package employee as function compute_raise_amount (percentage number); procedure hire_employee(); procedure fire_employee(); procedure list_employee_details(); end employee; Here we have encapsulated all employee “behaviors” into a single package that will be added into Oracle’s data dictionary. If we force our programmers to use stored procedures, the SQL moves out of the external programs and into the database, reducing the application programs into nothing more than a series of calls to Oracle stored procedures. As systems evolve and the majority of process code resides in stored procedures, Oracle’s shared pool becomes very important. The shared pool consists of the following subpools: • • • •
Dictionary cache Library cache Shared SQL areas Private SQL area (these exist during cursor open/cursor close)
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/505-507.html (2 of 3)4/03/2005 6:16:43
Oracle Databases on the Web:Database Performance And Tuning
• persistent area • runtime area As mentioned, the shared pool utilizes a least-recently-used algorithm to determine which objects are paged out of the shared pool. As this paging occurs, fragments, or discontiguous chunks of memory, are created within the shared pool. This means that a large procedure that initially fits into memory may not fit into contiguous memory when it’s reloaded after paging out. Consider the body of a package that has been paged out of an instance’s SGA because of other, more recent or frequent activity. Fragmentation will occur, and the server will not be able to find enough contiguous memory to reload the package body, resulting in an ORA-4031 error.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | <
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/505-507.html (3 of 3)4/03/2005 6:16:43
Oracle Databases on the Web:Database Performance And Tuning
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Pinning WebServer Packages In The SGA To prevent paging, packages can be marked as nonswappable, which tells the database that after their initial load they must always remain in memory. This is called pinning or memory fencing. Oracle provides a procedure called dbms_shared_pool.keep to pin a package. Packages can be unpinned with dbms_shared_pool.unkeep.
Note: Only packages can be pinned. Stored procedures cannot be pinned unless they are placed into a package.
The choice of whether to pin a package in memory is a function of the size of the object and the frequency of its use. Very large packages that are called frequently might benefit from pinning, but any difference may go unnoticed because the frequent calls to the procedure have kept it loaded into memory. Therefore, because the object never pages out, the pinning has no effect. Also, the way procedures are grouped into packages may have some influence. Some Oracle DBAs identify high-impact procedures and group them into a single package, which is pinned in the library cache. In an ideal world, the shared_pool parameter of the init.ora should be large enough to accept every package, stored procedure, and trigger that may be used by an application. However, reality dictates that the shared pool cannot grow indefinitely, and wise choices must be made in terms of which packages are pinned and which are excluded from the pinning routine. Because of their frequent usage, Oracle recommends that the standard, dbms_standard, dbms_utility, dbms_describe, and dbms_output packages always be pinned in the shared pool. To illustrate how pinning works, the following snippet demonstrates how a stored procedure called sys.standard can be pinned: connect internal; @/usr/oracle/rdbms/admin/dbmspool.sql execute dbms_shared_pool.keep('sys.standard'); A stored procedure can be written to pin all of the recommended Oracle packages into the shared pool. file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/507-511.html (1 of 3)4/03/2005 6:16:43
Oracle Databases on the Web:Database Performance And Tuning
Following is what this type of script might look like: EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE EXECUTE
dbms_shared_pool.keep('DBMS_ALERT'); dbms_shared_pool.keep('DBMS_DDL'); dbms_shared_pool.keep('DBMS_DESCRIBE'); dbms_shared_pool.keep('DBMS_LOCK'); dbms_shared_pool.keep('DBMS_OUTPUT'); dbms_shared_pool.keep('DBMS_PIPE'); dbms_shared_pool.keep('DBMS_SESSION'); dbms_shared_pool.keep('DBMS_SHARED_POOL'); dbms_shared_pool.keep('DBMS_STANDARD'); dbms_shared_pool.keep('DBMS_UTILITY'); dbms_shared_pool.keep('STANDARD');
Automatic Repinning Of Packages While this pinning routine ensures that a package stays pinned while the Oracle instance is running, you may also want to ensure that a package gets pinned each time the Oracle instance is started. Users of Oracle for Unix may want to add code to the /etc/rc file to ensure that the packages are repinned after each database startup. The rc file is generally maintained by the Unix system administrator, and this process guarantees that all packages are repinned with each bounce of the box. A pinning script might look like this: [root]: more pin ORACLE_SID=mydata export ORACLE_SID su oracle -c "/usr/oracle/bin/svrmgrl /<
How To Measure Pinned Packages How do we identify frequently accessed packages? The Oracle alert logs do not provide this information, and other methods must be found for sampling package usage. Listing 16.1 shows a handy script illustrating pinned packages in the SGA. This procedure could be run periodically and piped into a shell script that would maintain counts of the number of times each package has been called. Listing 16.1 Looking at pinned packages in the SGA. rem memory.sql Display used SGA memory for triggers, packages, and procedures SET PAGESIZE 60; COLUMN EXECUTIONS FORMAT 999,999,999; COLUMN Mem_used FORMAT 999,999,999; SELECT SUBSTR(owner,1,10) Owner, SUBSTR(type,1,12) Type, SUBSTR(name,1,20) Name, executions, sharable_mem Mem_used, SUBSTR(kept||' ',1,4) "Kept?" FROM v$db_object_cache WHERE TYPE IN ('TRIGGER','PROCEDURE','PACKAGE BODY','PACKAGE') file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/507-511.html (2 of 3)4/03/2005 6:16:43
Oracle Databases on the Web:Database Performance And Tuning
ORDER BY EXECUTIONS DESC; Listing 16.2 shows the output of memory.sql. Listing 16.2 The output of memory.sql. SQL> @memory OWNER
TYPE
SYS SYS SYS SYS SYS SYS SYS SYS HRIS SYS SYS HRIS HRIS HRIS HRIS HRIS SYS SYS KIS HRIS HRIS SYS HRIS SYS SYS SYS GIANT HRIS
PACKAGE PACKAGE BODY PACKAGE PACKAGE BODY PACKAGE PACKAGE BODY PACKAGE PACKAGE BODY PACKAGE PACKAGE PACKAGE BODY PACKAGE PACKAGE BODY PACKAGE BODY PACKAGE PACKAGE BODY PACKAGE PACKAGE BODY PROCEDURE PACKAGE PACKAGE BODY PACKAGE PROCEDURE PACKAGE BODY PACKAGE PACKAGE BODY PROCEDURE PROCEDURE
NAME STANDARD STANDARD DBMS_ALERT DBMS_ALERT DBMS_LOCK DBMS_LOCK DBMS_PIPE DBMS_PIPE S125_PACKAGE DBMS_UTILITY DBMS_UTILITY HRS_COMMON_PACKAGE S125_PACKAGE HRS_COMMON_PACKAGE GTS_SNAPSHOT_UTILITY GTS_SNAPSHOT_UTILITY DBMS_STANDARD DBMS_STANDARD RKA_INSERT HRS_PACKAGE HRS_PACKAGE DBMS_DESCRIBE CHECK_APP_ALERT DBMS_DESCRIBE DBMS_SESSION DBMS_SESSION CREATE_SESSION_RECOR INIT_APP_ALERT
EXECUTIONS 867,600 867,275 502,126 433,607 432,137 432,137 397,466 397,466 285,700 284,694 284,694 258,657 248,857 242,155 168,978 89,623 18,953 18,872 7,067 5,175 5,157 718 683 350 234 165 62 6
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/507-511.html (3 of 3)4/03/2005 6:16:43
MEM_USED 151,963 30,739 3,637 20,389 3,140 10,780 3,412 5,292 3,776 3,311 6,159 3,382 30,928 8,638 11,056 3,232 14,696 3,432 4,949 3,831 36,455 12,800 3,763 9,880 3,351 4,543 7,147 10,802
KEP YES YES NO NO YES YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO
Oracle Databases on the Web:Database Performance And Tuning
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
You can determine the number of times a nonpinned stored procedure has been swapped out of memory and required to reload. To effectively measure memory, two methods are recommended. The first recommended method is to regularly run the estat-bstat utility (usually located in ~/rdbms/admin/utlbstat.sql and utlestat.sql) to measure SGA consumption over a period of time. Another handy method would be writing a snapdump utility to interrogate the SGA and note any exceptional information relating to the library cache. This would include the following measurements: • Data dictionary hit ratio • Library cache miss ratio • Individual hit ratios for all namespaces Also, be aware that the relevant parameter, shared_pool_size, is used for other objects besides stored procedures. This means that one parameter fits all, and Oracle offers no method for isolating the amount of storage allocated to any subset of the shared pool. Here is a sample report for gathering information relating to shared_pool_size. Let’s say you see that your data dictionary hit ratio is above 95 percent and your library cache miss ratio is very low. You also notice that there are over 125,000 reloads in the SQL area namespace. At this point, you may want to increase the shared_pool_size. When running this type of report, always remember that statistics are gathered from startup and the numbers may be skewed. For example, on a system that has been running for six months, the data dictionary hit ratio will be a running average over six months. Consequently, data from the V$ structures is meaningless if you want to measure today’s statistics. Some Oracle DBAs will run utlbstat.sql, wait a short period, and then run utlestat.sql. This sequence produces a report called report.txt, where values can be extracted. One alternative is shown in Listing 16.3, which shows short customized statistics from the V$ tables in Oracle. Listing 16.3 A sample Oracle statistics utility. ========================= DATA DICT HIT RATIO ========================= (should be higher than 90 else increase shared_pool_size in init.ora) Data Dict. Gets 41,750,549
Data Dict. cache misses 407,609
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/511-514.html (1 of 3)4/03/2005 6:16:44
DATA DICT CACHE HIT RATIO 99
Oracle Databases on the Web:Database Performance And Tuning
========================= LIBRARY CACHE MISS RATIO ========================= (If > 1 then increase the shared_pool_size in init.ora) executions 22,909,643
Cache misses while executing 171,127
LIBRARY CACHE MISS RATIO .0075
========================= LIBRARY CACHE SECTION ========================= hit ratio should be > 70, and pin ratio > 70 ... NAMESPACE SQL AREA TABLE/PROCEDURE BODY TRIGGER INDEX CLUSTER OBJECT PIPE
Hit ratio 84 98 98 98 0 31 100 99
pin hit ratio 94 99 84 97 0 33 100 99
reloads 125,885 43,559 486 1,145
52
Let’s take a look at the SQL*Plus script (shown in Listing 16.4) that generated Listing 16.3. Listing 16.4 The script that generated Listing 16.3. PROMPT PROMPT PROMPT PROMPT PROMPT PROMPT (should PROMPT
========================= DATA DICT HIT RATIO ========================= be higher than 90 else increase shared_pool_size in
init.ora)
COLUMN "Data Dict. Gets" FORMAT 999,999,999 COLUMN "Data Dict. cache misses" FORMAT 999,999,999 SELECT sum(gets) "Data Dict. Gets", sum(getmisses) "Data Dict. cache misses", trunc((1-(sum(getmisses)/sum(gets)))*100) "DATA DICT CACHE HIT FROM v$rowcache; PROMPT PROMPT ========================= PROMPT LIBRARY CACHE MISS RATIO PROMPT ========================= PROMPT (If > 1 then increase the shared_pool_size in init.ora) PROMPT COLUMN "LIBRARY CACHE MISS RATIO" FORMAT 99.9999 COLUMN "executions" FORMAT 999,999,999 COLUMN "Cache misses while executing" format 999,999,999 SELECT sum(pins) "executions", sum(reloads) "Cache misses while (((sum(reloads)/sum(pins)))) "LIBRARY CACHE MISS RATIO" FROM v$librarycache; PROMPT PROMPT ========================= PROMPT LIBRARY CACHE SECTION PROMPT ========================= PROMPT hit ratio should be > 70, and pin ratio > 70 ... PROMPT
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/511-514.html (2 of 3)4/03/2005 6:16:44
RATIO"
executing",
Oracle Databases on the Web:Database Performance And Tuning
COLUMN "reloads" FORMAT 999,999,999 SELECT namespace, trunc(gethitratio * 100) "Hit ratio", trunc(pinhitratio * 100) "pin hit ratio", reloads "reloads" FROM v$librarycache; Just as the wisdom of the 1980s dictated that data should be centralized, the 1990s have begun an era where SQL is also centralized and managed. With the centralization of SQL, many previously impossible tasks have become trivial. For example: • SQL can easily be identified and reused. • SQL can be extracted by DBAs, enabling explain plan utilities to be run to determine the proper placement of table indexes. • SQL can be searched, allowing for fast identification of “where used” information. For example, when a column changes definition, all SQL referencing that column can be quickly identified. As memory becomes less expensive, it will eventually become desirable to have all of the application’s SQL and code loaded into the Oracle library cache, where the code will be available quickly for execution by any external applications, regardless of platform or host language. The most compelling reasons for putting all SQL within packages are portability and code management. If all applications become “SQL-less,” with calls to stored procedures, then entire applications can be ported to other platforms without altering a single line of the application code. As the cost of memory drops, 500 MB Oracle regions will not be uncommon. Until that time, however, DBAs must carefully consider the ramifications of pinning a package in the SGA.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/511-514.html (3 of 3)4/03/2005 6:16:44
Oracle Databases on the Web:Database Performance And Tuning
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Oracle Triggers Many database systems now support the use of triggers that can be fired at specific events. The insertion, modification, or deletion of a record may fire a trigger; or a business event, such as place_order, may initiate a trigger. Oracle Corporation claims that the design of their triggers closely follows the ANSI/ISO SQL3 draft standard (ANSI X3H6), but Oracle triggers are more robust in functionality than the ANSI standard. Triggers are defined at the schema level of the system, and will fire whenever an SQL select, update, delete, or insert command is issued. Remember that a trigger is always associated with a single DML event. Deciding When To Use A Trigger The choice of when to use a trigger and when to use a stored procedure can have a profound impact on the performance of the system. In general, triggers are used when additional processing is required as a row is inserted into a table. For example, assume that whenever a customer row is added, the system is required to look for the customer in the BAD_CREDIT table. If the customer appears in the BAD_CREDIT table, then its shipping_status column is set to COD. In this case, a trigger on insert of customer can fire the PL/SQL procedure to do the necessary lookup and set the shipping_status field to its appropriate value. Oracle triggers have the ability to call procedures, and a trigger may include SQL statements, thus providing the ability to nest SQL statements. Oracle triggers are stored as procedures that may be parameterized and used to simulate object-oriented behavior. For example, assume that we want to perform a behavior called check_total_inventory whenever an item is added to an order. (See Figure 16.1.)
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/514-518.html (1 of 3)4/03/2005 6:16:45
Oracle Databases on the Web:Database Performance And Tuning
Figure 16.1 The relationship among objects, triggers, and SQL. The trigger definition would be: create trigger check_total_inventory after select of item for each row select count(*) into :count from quantity where item_num = :myitem if :count < item.total then ...... end if; Triggers can also be combined to handle multiple events, such as the reordering of an item when the quantity-on-hand falls below a predefined level, as follows: create trigger reorder before update on item for each row when (new.reorderable = 'y') begin if new.qty_on_hand + old.qty_on_order < new.minimum_qty then insert into reorder values (item_nbr, reorder_qty); new.qty_on_order := old.qty_on_order + reorder_qty; end if; end;
Oracle Hashing Oracle7 now supports the concept of hash clusters. A hash cluster is a construct that works with Oracle clusters and uses the hashkeys command to allow fast access to the primary key for the cluster, thereby reducing I/O for your WebServer application. To reduce I/O, Oracle relies on a hashing algorithm, which takes a symbolic key and converts it into a row ID (rowid). The hashing function ensures that the cluster key is retrieved in a single I/O, which is faster than reading multiple blocks from an index tree. Because a hashing algorithm always produces the same key each time it reads an input value, duplicate keys have to be avoided. In Oracle, these collisions result when the values of hashkeys are less than the maximum number of cluster key values. For example, if a hash cluster uses the cust_nbr field as the key, and we know that there will be 50,000 unique cust_nbr values, then we must be sure that the value of hashkeys is set to at least 50,000. Also, you should always round up your value for hashkeys to the next highest prime number. Following is an example of a hash cluster: create cluster my_cluster (customer_nbr varchar(10)) tablespace user1 storage (initial 50k next 50k pctincrease 1) size 2k hash is customer_nbr hashkeys 50000; Now a table is defined within the cluster: create table customer ( customer_nbr number primary key) cluster my_cluster (customer_nbr);
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/514-518.html (2 of 3)4/03/2005 6:16:45
Oracle Databases on the Web:Database Performance And Tuning
The size parameter is usually set to the average row size for the table. Oracle recommends using a hash cluster when the following are true: • Use hash clusters to store tables commonly accessed by where clauses that specify equalities. • Only use hash clusters when you can afford to keep plenty of free space on each database block for updates. This value is set by the pctfree statement in the create table parameter. • Only use hash clusters if you are absolutely sure that you will not need to create a new, larger cluster at a later time. • Do not use a hash cluster if your table is commonly accessed by full-table scans, especially if a great deal of extra space from future growth has been allocated to the hash cluster. In a full-table scan, Oracle will read all blocks of the hash cluster, regardless of whether they contain any data rows. • Do not use a hash cluster if any of the hash cluster keys are frequently modified. Changing the value of a hash key causes the hashing algorithm to generate a new location, and the database will migrate the cluster to a new database block if the key value is changed. This is a very time-consuming operation. Keep in mind that the total size of the index columns must fit inside a single Oracle block. If the index contains too many long values, additional I/O will be required and updates and inserts will cause serious performance problems. Note the sample hashing routine shown in Figure 16.2.
Figure 16.2 A sample hashing routine. The database designer may choose to make the buffer blocks large to minimize I/O if the application clusters record on a database page. If a customer record is only 100 bytes, we will not gain by retrieving 32,000 bytes in order to get the 100 bytes that we need. However, if we cluster the orders physically near the customer (on the same database page), and if I/O usually proceeds from customer to order, then we will not need further I/O to retrieve orders for the customer.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/514-518.html (3 of 3)4/03/2005 6:16:45
Oracle Databases on the Web:Database Performance And Tuning
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Oracle Clusters Clustering is a very important concept for improving Oracle performance. As you know, when accessing Oracle, reducing I/O always improves throughput and overall performance. The concept of a cluster is very similar to the use of the VIA set in the CODASYL Network database model, where member records are stored physically near parent records. For Oracle, clusters can be used to define common one-to-many access paths, and the member rows can be stored on the same database block as their owner row. For example, assume that we have a one-to-many relationship between customers and orders. If our application commonly accesses the data from customer to order, we can cluster the order rows on the same database block as the customer row. In this way, we’ll receive the list of all orders for a customer in a single I/O. (See Figure 16.3.) Of course, we will need to size the database blocks with db_block_size so that an entire order will fit onto a single database block.
Figure 16.3 A sample Oracle cluster. We need to note one important issue: While a cluster will tremendously improve performance in one direction, queries in the other direction will suffer. For example, consider the many-to-many relationship between customers and orders. We have the junction table, ORDER_LINE, at the intersection of this many-to-many relationship and we need to decide which owner, ORDER or ITEM, will be the anchor for our cluster. If we commonly traverse from ORDER to ITEM (e.g., displaying an order form), it would make sense to cluster the ORDER_LINE records on the same database block as their ORDER owner. If, on the other hand, we commonly traversed from ITEM to ORDER (e.g., requesting the details for all orders containing widgets), file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/518-521.html (1 of 3)4/03/2005 6:16:46
Oracle Databases on the Web:Database Performance And Tuning
we would cluster the ORDER_LINE rows near their ITEM owner. If we cluster on the ORDER owner, database queries that display order forms will be very fast, while queries in the other direction will have to do additional I/O.
Oracle Parallel Query One of the most exciting performance features of Oracle version 7.3 and above is the ability to partition an SQL query into subqueries and dedicate separate processors to concurrently service each subquery. At this time, parallel query is useful only for queries that perform full-table scans on long tables, but the performance improvements can be dramatic. Here’s how it works. Instead of having a single query server manage the I/O against a table, parallel query allows the Oracle query server to dedicate many processors to acess the data, simultaneously, as shown in Figure 16.4.
Figure 16.4 A sample parallel query. To be most effective, the table should be partitioned onto separate disk devices, such that each process can do I/O against its segment of the table without interfering with the other simultaneous query processes. However, the client/server environment of the 1990s relies on RAID or a logical volume manager (LVM), which scrambles data files across disk packs in order to balance the I/O load. Consequently, full utilization of parallel query involves striping a table across numerous data files, each on a separate device. Even if your system uses RAID or LVM, some performance gains are still available with parallel query. In addition to using multiple processes to retrieve the table, the query manager will also dedicate numerous processes to simultaneously sort the result set. (See Figure 16.5.)
Figure 16.5 A sample parallel sort. Parallel query works best with symmetric multiprocessor (SMP) boxes, which have more than one internal CPU. Also, it is important to configure the system to maximize the I/O bandwidth, either through disk striping or high-speed channels. Because of the parallel sorting feature, it is also a good idea to beef up the memory of the processor. While sorting is no substitute for using a presorted index, the parallel query manager will service requests far faster than a single process. The data retrieval will not be significantly faster, though, because all of the retrieval processes will be competing for a channel on the same disk. Each sort process has its own sort area (as determined by the sort_area_size init.ora parameter), which speeds along the sorting of the result set.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/518-521.html (2 of 3)4/03/2005 6:16:46
Oracle Databases on the Web:Database Performance And Tuning
In addition to full-table scans and sorting, the parallel query option also allows parallel processing for merged joins and nested loops.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/518-521.html (3 of 3)4/03/2005 6:16:46
Oracle Databases on the Web:Database Performance And Tuning
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Invoking the parallel query option requires all indexing to be bypassed. And, most importantly, the execution plan for the query specifies a full-table scan. If the output of the explain plan does not indicate a full-table scan, the query can be forced to ignore the index by using query hints. The number of processors dedicated to service an SQL request is ultimately determined by the Oracle query manager, but the programmer can specify the upper limit on the number of simultaneous processes. When using the cost-based optimizer, the parallel hint can be embedded into the SQL to specify the number of processes. For example: select /*+ full(EMPLOYEE_TABLE) parallel(EMPLOYEE_TABLE, employee_name from EMPLOYEE_TABLE where emp_type = 'SALARIED';
4) */
If you are using SMP with many CPUs, you can issue a parallel request and leave it up to each Oracle instance to use their default degree of parallelism, as follows: select /*+ full(EMPLOYEE_TABLE) parallel(EMPLOYEE_TABLE, default, default) */ employee_name from EMPLOYEE_TABLE where emp_type = 'SALARIED'; Several important init.ora parameters have a direct impact on parallel query: • sort_area_size—The higher the value, the more memory available for individual sorts on each parallel process. Note that the sort_area_size parameter allocates memory for every query on the system that invokes a sort. For example, if a single query needs more memory and you increase the sort_area_size, all Oracle tasks will allocate the new amount of sort area, regardless of whether they will use all of the space. • parallel_min_servers—The minimum number of query servers active on the instance. System resources are involved in starting a query server, so having the query server started and waiting for requests will speed up processing. Note that if the actual number of required servers is less than the value of parallel_min_servers, the idle query servers will be consuming unnecessary overhead, and the value should be decreased. • parallel_max_servers—The maximum number of query servers allowed on the instance. This parameter file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/521-524.html (1 of 2)4/03/2005 6:16:46
Oracle Databases on the Web:Database Performance And Tuning
will prevent Oracle from starting so many query servers that the instance is unable to service all of them properly. To see how many parallel query servers are busy at any given time, the following query can be issued against the v $pq_sysstat table: select * from v$pq_sysstat where statistic = 'Servers Busy'; STATISTIC Servers Busy
VALUE 30
In this case, we see that 30 parallel servers are busy. Do not be misled by this number. Parallel query servers are constantly accepting work or returning to idle status, so it is a good idea to issue the query many times over a one hour period. Only then will you have a realistic measure of how many parallel query servers are being used.
Summary Now that we have covered the some of the tricks that can be used within Oracle to speed up WebServer queries, let’s take a look at the broader Oracle picture and explore how Oracle tuning can help WebServer at the system level. In the next chapter, we’ll explore how Oracle memory (SGA) can be tuned so that you’ll achieve maximum performance from your WebServer data requests.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch16/521-524.html (2 of 2)4/03/2005 6:16:46
Oracle Databases on the Web:Tuning Oracle SQL
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
CHAPTER 17 Tuning Oracle SQL Up until now, you’ve been reading about the physical Oracle database issues involved when creating a WebServer application; now let’s take a look at how Oracle’s SQL can be tuned to ensure optimal performance from WebServer. While several books have been devoted to the efficient use of Oracle SQL, only a handful of general rules and guidelines are effective in guaranteeing optimal performance from Oracle databases. This chapter focuses on the basic techniques for quickly achieving the maximum SQL performance with the least amount of effort. Topics in this chapter include: • • • • • •
Reviewing tips for creating efficient SQL Using index predicates Using concatenated indexes Improving performance using temporary tables Tuning with the rule-based optimizer Using hints with the cost-based optimizer
Tuning Oracle SQL Syntax SQL is a declarative language, so you can write a query many ways. And while each query might return identical results, the execution time can vary dramatically. To illustrate this concept, let’s consider a small employee table with 100 rows and an file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/525-528.html (1 of 3)4/03/2005 6:16:47
Oracle Databases on the Web:Tuning Oracle SQL
index on sex and hiredate. Let’s say you issue the following query to retrieve all female employees who have been hired within the last 90 days. The query uses Oracle’s rule-based optimizer, as follows: select emp_name from EMPLOYEE where sex = 'F' and hiredate between sysdate-90 and sysdate; Because the table has only 100 rows, the most efficient way to service this request would be to use a full-table scan. However, Oracle will walk the index that exists, performing dozens of extra I/Os as it reads the index tree to access the rows in the table. This simplistic example serves to illustrate the concept that the execution time of SQL is heavily dependent on the way a query is stated, as well as the internal index structures within Oracle. It’s true that each dialect of SQL is different, but general rules apply that can be used to keep database queries running efficiently. And while these guidelines are no substitute for the SQL explain plan facility, they can reduce the chances that a database query will consume large amounts of system resources. The first step is to look at the relative costs for each type of SQL access. Oracle has published the cost list shown in Table 17.1 that describes the relative cost of each type of SQL access. Table 17.1Costs for SQL access. Cost
Type of Operation
1
Single row by row ID (rowid)
2
Single row by cluster join
3
Single row by hash cluster key with unique or primary key
4
Single row by unique or primary key
5
Cluster join
6
Hash cluster key
7
Indexed cluster key
8
Use of a multicolumn index
9
Use of a single-column index
10
Bounded range search on indexed columns
11
Unbounded range search on unindexed columns
12
Sort-merge join
13
Max or min search of an indexed column
14
Use of order by on an indexed column
15
Full-table scan
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/525-528.html (2 of 3)4/03/2005 6:16:47
Oracle Databases on the Web:Tuning Oracle SQL
As you can see, the fastest way to retrieve a row is by knowing its row ID. A row ID (called a rowid in Oracle) is the number of the database block followed by the displacement, or position, of the row on the block. For example, 1221:3 refers to the third row on a page, on block number 1221. Many experienced Oracle programmers capture the rowid for a row if they plan to re-retrieve it. In Oracle, rowid is a valid column statement, such that you can select the rowid along with your data in a single statement, such as: select rowid from EMPLOYEE into :myvar; Inside a WebServer application, PL/SQL storage arrays can be defined to hold rowid values. For details, see Chapter 8, WebServer’s OWA Utilities. When creating WebServer applications, keep in mind that the most expensive SQL statement is one that invokes a full-table scan. As you may know, a full-table scan is acceptable for small tables, but it can wreak havoc on an entire Oracle instance when a full-table scan is invoked against a large table. Therefore, more than any other SQL tuning technique, avoiding large-table full-table scans is a primary consideration. With proper tuning of Oracle SQL, full-table scans can usually be avoided by using indexes and index hints. What about queries that need to read every row of a table? While a full-table scan may be the fastest for an individual query where every row in the table must be read (i.e., using sum, avg, or queries with many complex where conditions), the full-table scan is done at the expense of other SQL on the system. As a large-table full-table scan reads rows into memory, buffer pages containing rows from other queries will be flushed from the buffer, and Oracle will need to re-retrieve these rows. So, the question is, do you tune an individual query for performance, or do you tune the database as a whole? Generally speaking, we cannot allow a single query to achieve good response time at the expense of all other tasks on the database.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/525-528.html (3 of 3)4/03/2005 6:16:47
Oracle Databases on the Web:Tuning Oracle SQL
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
General Tips For Efficient SQL Fortunately, some general rules are available for writing efficient SQL in Oracle. These rules may seem simplistic, but diligently following them will relieve more than half of your SQL tuning problems. • Never do a calculation on an indexed column (e.g., where salary*5 > :myvalue). • Whenever possible, use the union statement instead of or. • Avoid the use of not in or having in the where clause. Instead, use the not exists clause. • Always specify numeric values in numeric form and character values in character form (e.g., where emp_number = 565, where emp_name = ‘Jones’). • Avoid specifying NULL on an indexed column. • Avoid the like parameter if = will suffice. Using any Oracle functions will invalidate the index, causing a full-table scan. • Never mix datatypes in Oracle queries, as it will invalidate the index. If the column is numeric, remember not to use quotes (e.g., salary = 50000). For char index columns, always use quotes (e.g., name = ‘BURLESON’). • Remember that Oracle’s rule-based optimizer looks at the order of table names in the from clause to determine the driving table. Always make sure that the last table specified in the from clause is the table that will return the smallest number of rows. In other words, specify multiple tables with the largest result set table specified first in the where clause. • Avoid using subqueries when a join will do the job. • Use the Oracle decode function to minimize the number of times a table has to be selected. • To turn off an index you do not want to use (only with cost-based), concatenate a
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/528-532.html (1 of 4)4/03/2005 6:16:47
Oracle Databases on the Web:Tuning Oracle SQL
null string to the index column name (e.g., name||‘’), or add zero to a numeric column name (e.g., salary+0). • If your query will return more than 20 percent of the rows in the table, use a fulltable scan rather than an index scan. • Always use table aliases when referencing columns. Historically, queries pose a common problem with SQL. Simple queries can be written in many different ways, each variant of the query producing the same result but with widely different access methods and query speeds. For example, a simple query such as “What students received an A last semester?” can be written in three ways, as shown in Listings 17.1, 17.2, and 17.3, each returning an identical result. Listing 17.1 A standard join. select * from STUDENT, REGISTRATION where STUDENT.student_id = REGISTRATION.student_id and REGISTRATION.grade = 'A'; Listing 17.2 A nested query. select * from STUDENT where student_id = (select student_id from REGISTRATION where grade = 'A' ); Listing 17.3 A correlated subquery. select * from STUDENT where 0 < (select count(*) from REGISTRATION where grade = 'A' and student_id = STUDENT.student_id ); Each of these queries will return identical results, but the access path that the queries take through the Oracle database varies greatly.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/528-532.html (2 of 4)4/03/2005 6:16:47
Oracle Databases on the Web:Tuning Oracle SQL
The following discussion will review the basic components of an SQL query, showing how to optimize a query for remote execution. It is important to note that several steps are required to understand how SQL is used in a distributed database. Distributed SQL queries function in the same way as queries within a single database, with the exception that crossdatabase joins and updates may utilize indexes that reside on different databases. Regardless, a basic understanding of the behavior of SQL can lead to dramatic performance improvements.
Using Oracle’s Explain Plan Facility Because SQL is a declarative language, it is not immediately apparent how an SQL query is being serviced. Whether or not Oracle is using an index, performing a full-table scan, or performing a merge sort, is hidden from view. Fortunately, tools exist within Oracle’s implementation of SQL that allow the access path to be interrogated. To see the output of an explain plan, you must first create a plan table to store the output from the explain. Oracle provides a script in $ORACLE_HOME/rdbms/admin with a script called utlxplan.sql. Execute utlxplan.sql, and create a public synonym for the PLAN_TABLE, as follows: sqlplus>@utlxplan table created. sqlplus > create public synonym PLAN_TABLE for SYS.PLAN_TABLE; synonym created. Oracle uses the explain utility by taking the SQL statement as input, running the SQL optimizer, and then sending the access path information into a PLAN_TABLE, which can then be interrogated to see the access methods. Listing 17.4 runs a query against a sales database to get the sum of costs for a particular month. Listing 17.4 A database query against a sales database. explain plan set statement_id = 'test1' for set statement_id = 'run1' into PLAN_TABLE for select 'T'||costsnet.terr_code, 'P'||detcost.pac1 || detcost.pac2 || detcost.pac3, 'P1', sum(costsnet.ytd_d_ly_tm), sum(costsnet.ytd_d_ty_tm), sum(costsnet.jan_d_ly), sum(costsnet.jan_d_ty), from costsnet, detcost where costsnet.mgc = detcost.mktgpm and detcost.pac1 in ('N33','192','195','201','BAI', 'P51','Q27','180','181','183','184','186','188', '198','204','207','209','211') group by 'T'||costsnet.terr_code, file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/528-532.html (3 of 4)4/03/2005 6:16:47
Oracle Databases on the Web:Tuning Oracle SQL
'P'||detcost.pac1 || detcost.pac2 || detcost.pac3; This syntax is piped into the SQL optimizer, which will analyze the query and store the plan information in a row in the plan table identified by RUN1. Please note that the query will not execute; it will only create the internal access information in the plan table. The plan table contains the following fields: • operation—Type of access being performed. Usually table access, table merge, sort, or index operation. • options—Modifiers to the operation, specifying a full table, a range table, or a join. • object_name—Name of the table being used by the query component. • process ID—Identifier for the query component. • parent ID—Parent of the query component. Note that several query components may have the same parent.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/528-532.html (4 of 4)4/03/2005 6:16:47
Oracle Databases on the Web:Tuning Oracle SQL
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Now that the PLAN_TABLE has been created and populated, you may interrogate it to see your output by running the following query: rem plan.sql - displays contents of the explain plan table set pages 9999; select lpad(' ',2*(level-1))||operation operation, options, object_name, position from plan_table start with id=0 and statement_id = 'RUN1' connect by prior id = parent_id and statement_id = 'RUN1'; Listing 17.5 shows the output from the plan table. Listing 17.5 The plan table’s output. SQL>@list_explain_plan OPERATION ——————————————————————————————————— OPTIONS OBJECT_NAME ————————————— ——————————————— SELECT STATEMENT SORT GROUP BY
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/532-535.html (1 of 3)4/03/2005 6:16:48
POSITION ————————————
1
Oracle Databases on the Web:Tuning Oracle SQL
CONCATENATION 1 NESTED LOOPS TABLE ACCESS FULL
COSTSNET
1 1
TABLE ACCESS BY ROWID
DETCOST
2
INDEX RANGE SCAN
DETCOST_INDEX5
1
NESTED LOOPS From this output, you can see the dreaded table access full on the COSTSNET table. To diagnose the reason, return to the SQL and look for any COSTSNET columns in the where clause. There you can see that the COSTSNET column called mgc is being used as a join column in the query, indicating that an index is necessary on COSTSNET.mgc to alleviate the full-table scan. While the plan table is useful for determining the access path to the data, it doesn’t tell the whole story. The configuration of the data is also a consideration. While the SQL optimizer is aware of the number of rows in each table (the cardinality) and the presence of indexes on fields, the SQL optimizer is not aware of data distribution factors, such as the number of expected rows returned from each query component. The other tool used with the plan table is an SQL trace facility. Most database management systems provide a trace facility that shows the resources consumed within each query component. The trace table will show the number of I/Os required to perform the SQL, as well as the processor time for each query component. Some other relational databases, such as DB2, allow the DBA to specify the physical sequence for storing the rows. Generally, this sequence will correspond to the column value most commonly used when the table is read sequentially by an application. If a customer table is frequently accessed in customer ID order, then the rows should be physically stored in customer ID sequence. The explain plan output will display many database access methods. The major access techniques include: • and-equal—Indicates that tables are being joined and that Oracle will be able to use the values from the indexes to join the rows. • concatenation—Indicates an SQL union operation. • counting—Indicates the use of the SQL count function. • filter—Indicates that the where clause is removing unwanted rows from the result set. • first row—Indicates that a cursor has been declared for the query. • for update—Indicates that returned rows were write locked (usually by using the select…for update of…). • index (unique)—Indicates that an index was scanned for a value specified in the where clause. • index (range scan)—Indicates that a numeric index was scanned for a range of values (usually with the between, less_than, or greater_than specified). • intersection—Indicates a solution set from two joined tables. • merge join—Indicates that two result sets were used to resolve the query. • nested loops—Indicates that the last operation will be performed n times, once for each preceding operation. For example, below the index (unique), these operations will be performed for each row returned by table access (full): nested loops, table access (full) of ‘customer’, and index (unique) of sy_01_idx. • projection—Indicates that only certain columns from a selected row are to be returned. • sort—Indicates a sort, either into memory or the TEMP tablespace. • table access (rowid)—Indicates a row access by rowid that is very fast. • table access (full)—Indicates a full-table scan and is usually cause for concern unless the
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/532-535.html (2 of 3)4/03/2005 6:16:48
Oracle Databases on the Web:Tuning Oracle SQL
table is very small. • union—Indicates that the distinct SQL clause was probably used. • view—Indicates that an SQL view was involved in the query. Database statistics packages can be made to capture this information, but they tend to be very resource intensive. Turning on SQL trace statistics for a very short period of time during processing is a good practice to follow and enables you to gather a representative sample of the SQL access. Using Temporary Tables The prudent use of temporary tables can dramatically improve WebServer performance. Consider the following example. You want to identify all users who exist within Oracle, but have not been granted a role. You could formulate the following query: select username from dba_users where username not in (select grantee from dba_role_privs); This query runs in 18 seconds. Now, you could rewrite the same query to utilize temporary tables, as follows: create table temp1 as select distinct username from dba_users; create table temp2 as select distinct grantee from dba_role_privs; select username from temp1 where username not in (select grantee from temp2); This query runs in less than 3 seconds.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/532-535.html (3 of 3)4/03/2005 6:16:48
Oracle Databases on the Web:Tuning Oracle SQL
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
FAQ/ site help map
search
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Tuning With The Rule-Based Optimizer In Oracle’s rule-based optimizer, the ordering of the table names in the from clause determines the driving table. The driving table is important because it is retrieved first, and the rows from the second table are then merged into the result set from the first table. Therefore, it is essential that the second table returns the least amount of rows based on the where clause. This is not always the table with the least amount of rows (i.e., the smallest cardinality). For example, consider two EMP_TABLEs—one in London and another in New York, as shown in Table 17.2. Table 17.2New York and London EMP_TABLES. Rows
Dpt 100
Dpt 200
New York
1,000
100
900
London
200
150
50
In this example, a total select from the EMP_TABLE should specify the New York table first because London has the least amount of returned rows. The SQL should appear as follows: select * from emp@new_york, emp@london; file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/535-539.html (1 of 4)4/03/2005 6:16:49
Oracle Databases on the Web:Tuning Oracle SQL
If the SQL specifies a where condition to include only Department 100, the order of table names should be reversed, as follows: select * from emp@london, emp@new_york where DEPT = 100; It’s not always known what table will return the least amount of rows, so procedural code could be used to interrogate the tables and specify the tables in their proper order. This type of SQL generation can be very useful for ensuring optimal database performance, as shown in Listing 17.6. Listing 17.6 Automatic generation of optimal rule-based SQL. select count(*) into :my_london_dept from emp@london where dept = :my_dept; select count(*) into :my_ny_dept from emp@new_york where dept = :my_dept; if my_london_dept >= my_ny_dept { table_1 = emp@london table_2 = emp@new_york else table_1 = emp@new_york table_2 = emp@london } /* Now we construct the SQL */ select * from :table_1, :table_2 where dept = :my_dept; As you probably know, Oracle version 7 offers two methods of tuning SQL. If you are running version 7.2 or above, you can use the cost-based optimizer; releases of Oracle 7.1 and below require the rule-based optimizer. With the rule-based optimizer, the indexing of tables and order of clauses within an SQL statement control the access path. The cost-based optimizer automatically determines the most efficient execution path, and the programmer is given hints that can be added to the query to alter the access path. The cost-based optimizer or the rule-based optimizer is set in the init.ora file when the DBA sets the optimizer_mode to rule, choose, first_rows, or all_rows. Beware of using the choose option. When you give Oracle the ability to choose the optimizer mode, Oracle will favor the cost-based approach if any of the tables in the
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/535-539.html (2 of 4)4/03/2005 6:16:49
Oracle Databases on the Web:Tuning Oracle SQL
query contains statistics. (Statistics are created with the analyze table command.) For example, if a three-table join is specified in choose mode and statistics exist for one of the three tables, Oracle will decide to use the cost-based optimizer and will issue an analyze table estimate statistics at runtime. This will dramatically slow down the query. The optimizer option (rule versus cost) can be controlled at the database level or at the program level. Prior to version 7.0.16, the cost-based analyzer had significant problems, and Oracle recommended the use of the rule-based optimizer. Here are some tips for effective use of Oracle’s rule-based optimizer: • Try changing the order of the tables listed in the from clause. Page 1915 in Oracle RDBMS Database Administrator’s Guide states, “Joins should be driven from tables returning fewer rows rather than tables returning more rows.” In other words, the table that returns the fewest rows should be listed last. This usually means that the table with the most rows is listed first. If the tables in the statement have indexes, the driving table is determined by the indexes. One Oracle developer recently slashed processing time in half by changing the order of the tables in the from clause. Another developer had a process shift from running for 12 hours to completing in 30 minutes by changing the from clause. • Try changing the order of the statements in the where clause. Here’s the idea: Assume that an SQL query contains an if statement with several boolean expressions separated by ands. Oracle parses the SQL from the bottom of the SQL statement in reverse order. Therefore, the most restrictive boolean expression should be on the bottom. For example, consider the following query: select last_name from STUDENT where eye_color = 'BLUE' and national_origin = 'SWEDEN';
Here, the number of students from Sweden is assumed to be smaller than the number of students with blue eyes. To further confound matters, if an SQL statement contains a compound if separated by ors, the rule-based optimizer parses from the top of the where clause. Therefore, the most restrictive clause should be the first boolean item in the if statement. • Analyze the existence/nonexistence of indexes; understand your data. Again, unlike the cost-based optimizer, the rule-based optimizer only recognizes the existence of indexes and does not know about the selectivity or the distribution of the index column. Consequently, use care when creating indexes, especially when using rule-based optimization. Consider all programs that use a field in a where clause of a select. A field should only be indexed when a very small subset (less than 10 percent) of the data will be returned. • Check to see if the target table is fragmented. For example, a table could be fragmented if it constantly has a large number of rows inserted and deleted. file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/535-539.html (3 of 4)4/03/2005 6:16:49
Oracle Databases on the Web:Tuning Oracle SQL
This is especially true in pctfree because the table has been set to a low number. Regular compression of the table with Oracle’s export/import utility will restore the table row and remove fragmentation. • Always run questionable SQL through explain plan to examine the access path. • Understand which “query paths” are the fastest. For example, accessing a table by rowid is the fastest access method available where a full-table scan is 17 out of 18 for the ranking of query paths. (Reference Table 17.1 for the complete list of relative costs.) • Avoid joins that use database links into Oracle version 6 tables. • Make effective use of arrays. Array processing significantly reduces database I/O. Consider the following example. A table has 1,000 rows to be selected. The records are manipulated and then updated in the database. Without using array processing, the database receives 1,000 reads and 1,000 updates. With array processing (assuming an array size of 100), the database receives 10 reads (1,000/100) and 10 updates. According to Oracle, increasing the array size to more than 100 has little benefit. Beware of an Oracle rule-based “feature” whereby a join of numerous large tables will always result in a full-table scan on one of the tables, even if all of the tables have indexes and the join could be achieved with an index scan. Of course, full-table scans are costly, and SQL hints can be used to force the query to use the indexes. You can use hints with the rule-based optimizer.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/535-539.html (4 of 4)4/03/2005 6:16:49
Oracle Databases on the Web:Tuning Oracle SQL
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Using Hints With The Cost-Based Optimizer The rule-based optimizer is supposed to be obsolete with the introduction of Oracle version 8, but its replacement—the cost-based optimizer—is already available today. Unlike the rule-based optimizer, which uses heuristics to determine the access path, the cost-based optimizer uses data statistics to determine the most efficient way to service the request. Here is a summary of the most common hints that can be added to SQL: • all_rows—This is the cost-based approach designed to provide the best overall throughput. • cluster—Requests a cluster scan of the table(s). • first_rows—This is the cost-based approach designed to provide the best response time. • full—Requests the bypassing of indexes doing a full-table scan. • index—Requests the use of the specified index. If no index is specified, Oracle will choose the best index. • rowid—Requests a rowid scan of the specified table. • rule—Indicates that the rule-based optimizer has been invoked (sometimes to the absence of table statistics). • ordered—Requests that the tables should be joined in the order that they are specified. For example, if you know that a STATE table has only 50 rows, you may want to use this hint to make STATE the driving table. • use_nl—Requests a nested loop operation with the specified table as the driving
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/539-541.html (1 of 3)4/03/2005 6:16:49
Oracle Databases on the Web:Tuning Oracle SQL
table. • use_merge—Requests a sort-merge operation. Remember, the cost-based optimizer will only be as accurate as the statistics computed from the tables. The DBA will need to create a periodic cron job for statistics. This job will re-estimate statistics for tables that are volatile and change columns frequently. While a full analyze table xxx estimate statistics will interrogate every row of the table, a faster method can be used by issuing analyze table estimate statistics sample nn rows. By taking a sample of the rows within the table, the statistics generation will run much faster. Keep in mind that one of the things the analyze command reviews is the selectivity and distribution of values within an index. As such, care should be taken to sample at least 100 rows from each table. Here is a test that created a set of three tables—DEPT, DEPT1, and DEPT2—each with an index on deptno and set optimizer_goal as rule in the init.ora. Listing 17.7 shows the results of the query. Listing 17.7 The results of the execution plan query. select /*+ INDEX(dept DEPT_PRIMARY_KEY) INDEX(dept2 i_dept2) INDEX(dept1 i_dept1)*/ dept.deptno, dept1.dname, dept2.loc from dept, dept1, dept2 where dept.deptno=dept1.deptno and dept1.deptno=dept2.deptno Misses in library cache during parse: 1 Optimizer hint: RULE Parsing user id: 48 (DON) Rows ——— 0 4 4 4 5 4 8 4 4 5
Execution Plan ————————————————————————— SELECT STATEMENT OPTIMIZER HINT: RULE MERGE JOIN SORT (JOIN) NESTED LOOPS INDEX (RANGE SCAN) OF 'DEPT_PRIMARY_KEY' (UNIQUE) TABLE ACCESS (BY ROWID) OF 'DEPT1' INDEX (RANGE SCAN) OF 'I_DEPT1' (NON-UNIQUE) SORT (JOIN) TABLE ACCESS (BY ROWID) OF 'DEPT2' INDEX (RANGE SCAN) OF 'I_DEPT2' (NON-UNIQUE)
Listing 17.8 shows the previous query’s results without any hints. Listing 17.8 The query results with no hints. select dept.deptno, dept1.dname, dept2.loc from dept, dept1, dept2 where dept.deptno=dept1.deptno and dept1.deptno=dept2.deptno file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/539-541.html (2 of 3)4/03/2005 6:16:49
Oracle Databases on the Web:Tuning Oracle SQL
Misses in library cache during parse: 1 Optimizer hint: RULE Parsing user id: 48 (JACK) Rows ——— 0 4 4 4 4 8 4
Execution Plan ————————————————————————— SELECT STATEMENT OPTIMIZER HINT: RULE NESTED LOOPS NESTED LOOPS TABLE ACCESS (FULL) OF 'DEPT2' TABLE ACCESS (BY ROWID) OF 'DEPT1' INDEX (RANGE SCAN) OF 'I_DEPT1' (NON-UNIQUE) INDEX (UNIQUE SCAN) OF 'DEPT_PRIMARY_KEY' (UNIQUE)
If a hint was added for the DEPT2 index, the full-table scan would be on DEPT1, and so on.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/539-541.html (3 of 3)4/03/2005 6:16:49
Oracle Databases on the Web:Tuning Oracle SQL
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Tuning PL/SQL Procedure Language/SQL is the standard procedural language for WebServer applications. PL/ SQL is also commonly used within Oracle’s SQL*Forms application framework. But the reemergence of PL/SQL’s popularity for non-SQL*Forms applications can be attributed to the benefits of using Oracle stored procedures—which must be written with PL/SQL. It is Oracle’s stored procedures that make the htp utilities possible for WebServer implementation. PL/SQL offers the standard language constructs, including looping, if statements, assignment statements, and error handling. There are several problems with PL/SQL, each of which warrants special attention. PL/SQL offers two types of SQL cursors: the explicit cursor and the implicit cursor. Explicit cursors are manually declared in the PL/SQL, as follows: DECLARE CURSOR C1 IS select last_name from customer where cust_id = 1234; However, it’s possible to issue the SQL statement directly in PL/SQL without specifying the cursor name. When this happens, Oracle opens an implicit cursor to handle the request. Implicit cursors create a tremendous burden for Oracle, as the implicit cursor must always reissue a fetch command to ensure that only a single row is returned by the query. This will double the amount of fetch statements for the query. The moral is simple: Always declare all cursors in your PL/ SQL. PL/SQL allows certain types of correlated subqueries to run much faster than traditional Oracle
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/541-544.html (1 of 3)4/03/2005 6:16:50
Oracle Databases on the Web:Tuning Oracle SQL
SQL queries. This is a critical issue with WebServer, because it may be much faster to embed all Oracle SQL in PL/SQL rather than embedding the SQL in Perl or Java. To illustrate why WebServer may run faster with PL/SQL than with Perl or Java SQL, consider a situation where a bank maintains a general ledger table and a transaction table. At the end of the banking day, the check transaction table is applied to the GENERAL_LEDGER table, making the requisite deductions from the account_balance column. Let’s assume that the GENERAL_LEDGER table contains 100,000 rows and 5,000 daily checks need to be processed. A traditional SQL query (shown in Listing 17.9) used to accomplish the updating of account_balance would involve a correlated subquery. This is the type of SQL that you might embed into a Perl or Java script for a WebServer application. Listing 17.9 Using a traditional SQL query. update general_ledger set account_balance = account_balance (select check_amount from transaction where transaction.account_number = general_ledger.account_number) where exists (select 'x' from transaction where transaction.account_number = general_ledger.account_number); When Oracle detects a correlated subquery, Oracle will execute the subquery first, and then apply the query result to the entire outer query. In this case, the inner query will execute 5,000 times, and the outer query will be executed once for each row returned from the inner query. This is called a Cartesian product and has always been a problem for this type of query. Now, consider the identical query written in PL/SQL, as shown in Listing 17.10. Listing 17.10 The PL/SQL query. DECLARE CURSOR c1 is select account_number, check_amount from transaction; keep_account_number keep_check_amount
number; number;
BEGIN OPEN C1; LOOP fetch C1 into keep_account_number, keep check_amount; exit when C1%NOTFOUND; update general_ledger set account_balance = account_balance - keep_check_amount where account_number = keep_account_number; END LOOP; file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/541-544.html (2 of 3)4/03/2005 6:16:50
Oracle Databases on the Web:Tuning Oracle SQL
END; Here you can see that each check amount is retrieved in a separate transaction and fetched into cursor C1. For each check_amount, the balance is applied to the GENERAL_LEDGER row, one at a time.
Summary Now that you’ve reviewed Oracle database tuning for WebServer, let’s take a look into the future to get an idea how the nature will be changing. As you may know, the next major release of Oracle (version 8) will have object-oriented features, and the WebServer developer will benefit from understanding how these changes to the Oracle architecture will affect the Oracle WebServer product.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch17/541-544.html (3 of 3)4/03/2005 6:16:50
Oracle Databases on the Web:The Future Of Database Management
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
CHAPTER 18 The Future Of Database Management While Oracle WebServer is considered cutting-edge technology today, it will only be a few short years before the technology again shifts direction. The introduction of Oracle version 8, the concept of a “universal” database server, and the advances in hardware technology are combining to present an exciting future for Oracle applications. Many new terms are being used to describe future database systems—knowledgebases, intelligent databases, neural databases, and database machines are but a few. Oracle version 8 is just the beginning.
Oracle Version 8 The next progression of database architectures is moving toward object-oriented databases. Early file managers stored data; network databases stored data and relationships; object-oriented databases will store data, data relationships, and the behaviors of the data. In general, the Oracle8 engine is remarkably similar to the relational engine found in Oracle 7.3, but with major extensions to the relational architecture. It is interesting to note that Oracle has not discarded the idea of creating a “universal” database engine. Oracle is calling Oracle8 the “Oracle Universal Server,” adding text and multidimensional and object capabilities to the relational engine. The most exciting enhancements involve the introduction of Sedona, the incorporation of the Oracle file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/545-548.html (1 of 3)4/03/2005 6:16:51
Oracle Databases on the Web:The Future Of Database Management
Express MDDB, and the “object layer” that will be tightly coupled with the relational engine. Oracle Sedona Due to the secrecy around the development of Oracle8, many Oracle professionals assumed that Sedona was the code name for Oracle8. However, Sedona is actually an extension to Oracle8. Sedona has been billed as a universal object manager, and it appears that its basic function is to act as an object consolidator. Sedona will allow for Oracle methods to be indexed and quickly located across many databases and platforms. Sedona achieves this by placing an object wrapper around Oracle objects so that they can be accessed by other distributed systems. While the details are sketchy, Sedona will incorporate many of the features of an Object Request Broker (ORB), with a metadata dictionary for the distributed management of objects. With Sedona, object classes may be registered in a central repository so that they will be available for use transparently across the enterprise. Oracle has made the interface specifications for Sedona available to third-party software vendors, hoping that vendors will create application products utilizing Sedona. Oracle ConText A text searching option called Oracle ConText has also been added to the relational engine of Oracle8. Oracle ConText allows thematic word searching capabilities against Oracle’s relational database. Although the ConText option indexes on each word within the text, the real power of the text retrieval system is located in the frontend software. While this represents a major improvement over Oracle Book (which is now obsolete), it remains to be seen how ConText will compete in the marketplace as a text search engine. There are two fundamental ways to measure the accuracy of text retrieval: • Precision—Retrieves only relevant documents (no false or “noisy” hits). • Recall—Retrieves all relevant documents in a given data collection. Together, precision and recall represent the overall accuracy of a text retrieval system. Natural language is a phrase frequently heard in conjunction with concept-based searching, and morphology is a term commonly used by text databases to simulate natural language query. Morphology recognizes basic units of meaning and parts of speech. To understand morphology, consider the phrase “Please write to Mr. Wright right now.” To the human ear, all of the words sound identical; the meaning of the words can be determined only by the context of the sentence. From the initial review, it is still unclear how well Oracle ConText will be able to compete with the other more established text engines such as ConQuest, Fulcrum, and Folio. Oracle Express Unlike Oracle 7.3, where the Express multidimensional database was installed independently of Oracle, the Express product has been incorporated into the Oracle8 kernel. This implies yet another change for Oracle DBAs, who must now manage both the relational and multidimensional components of Oracle. Oracle Express will be offered for NT and PC, as well as Unix platforms. The basic reporting functions of
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/545-548.html (2 of 3)4/03/2005 6:16:51
Oracle Databases on the Web:The Future Of Database Management
Express have been enhanced to provide forecasting and model building. Unlike the Express product developed by IRI, Oracle Express has been enhanced so that it does not require data to be preloaded into its internal data structures. This enhancement enables Express to read relational data directly from relational Oracle databases, dynamically transforming and aggregating the data for multidimensional presentation. This means that Express will now compete against other relational backend products, such as Holos and MetaCube. SQL For Object-Orientation The object-oriented approach borrows heavily from C++ and Smalltalk. Both languages allow for the storing of behaviors with the data, such that data and business rules share a common repository. With the properties of encapsulation, abstraction, and polymorphism, object technology systems are moving toward a unified data model that models the real world far more effectively than previous modeling techniques. Furthermore, a properly designed object-oriented model promises to be maintenance-free, because all changes to data attributes and behaviors become a database task—not a programming task. The distinguishing characteristic of the object-oriented database is its ability to store data behavior. At first glance, incorporating data into the database may seem to be a method for moving application code from a program into a database. While it is true that an object-oriented database stores behaviors, these databases must also have the ability to manage many different objects—each with different data items.
Previous Table of Contents Next
Products | Contact Us | About Us |
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/545-548.html (3 of 3)4/03/2005 6:16:51
Oracle Databases on the Web:The Future Of Database Management
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
The ISA Relationship As presented earlier in this book, the ISA relationship is a data relationship that indicates a type/subtype data relationship. While traditional E/R modeling deals only with single entities, the ISA approach recognizes that many “types” or classes of an individual entity may exist. In fact, the ISA relationship is the foundation of objectoriented programming, which allows the designer to create hierarchies of related classes and then use inheritance and polymorphism to control which data items will participate in the low-level objects. Oracle is planning to introduce an extension to their Designer/2000 product to allow for the modeling of class hierarchies. This new extension, tentatively dubbed Designer/2001, should allow for object-oriented constructs to be described and modeled.
The ODMG Object Model ODMG is a vendor organization dedicated to providing standards for object-oriented databases. The ODMG object model was developed jointly by a consortium of objectoriented database vendors. These companies feel a sense of urgency to create a unified standard for object-oriented databases, and they have prepared the ODMG model in the hope that all OODB vendors will adopt the model. Current commercial OODB systems are not portable across hardware platforms, and it is hoped that a joint approach toward object-oriented database architecture will create an environment where object-oriented systems share many characteristics, just as relational databases file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/548-551.html (1 of 3)4/03/2005 6:16:51
Oracle Databases on the Web:The Future Of Database Management
share common interfaces, such as SQL. Because of a lack of standards for object-oriented database architectures, most of the major OODB vendors have been creating commercial products with very diverse internal structures. A recent effort has been made to propose a standard architecture for object-oriented database systems (Loomis, 1993), and this standard may become the foundation for an industry-wide architecture for object-oriented databases. The ODMG object model was developed jointly by a consortium of object-oriented database vendors, including Versant, Ontos, O2 Technology, Object Design, SunSoft, and Objectivity corporations. Notably absent is Microsoft. While we can only speculate about Microsoft’s failure to participate in these standards, their market dominance may have something to do with their level of participation. The other companies feel a sense of urgency in creating a unified standard for object-oriented databases, and they have prepared the ODMG model in the hope that all OODB vendors will adopt the model. The ODMG model creates an independent model that is language independent, and object models may be bound to many different languages. ODMG develops a hierarchy of objects with the most general object called a denotable object. Denotable objects may be mutable or immutable. A mutable object may change its values and properties, but an immutable object contains only literal values. Within immutable objects, we find two subcategories: atomic and structured (as shown in Figure 18.1). A denotable, immutable, atomic object is represented by the same datatypes found in relational databases, namely char, integer, and float. A denotable, immutable, structured object is a literal structure such as the date and time datatypes.
Figure 18.1 The ODMG object model. Unlike the relational database model, the ODMG model requires that all objects are assigned an object identifier (OID) to uniquely identify each object. While still unclear, it appears that it is not possible to reference an object by the data values in the object. For example, in a relational database, one could state select * from order where order_nbr = 123; this would not be possible under the current ODMG object model. Rather, the ODMG model requires database currency to locate the object, and the system must know the OID. The ODMG model also categorizes objects according to their lifetime within the runtime system. Temporary objects, those associated with a procedure or a process, are classified separately from database objects, which require external storage. The ODMG object model also attempts to redefine the basic principles of entity/ relationship modeling, but carries the concept one step further, specifying directionality when navigating the data relationship. file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/548-551.html (2 of 3)4/03/2005 6:16:51
Oracle Databases on the Web:The Future Of Database Management
This model also specifies navigational operators to traverse the linked-list data structures found in commercial implementations of object-oriented databases. These operators are remarkably similar to the DML found in other pointer-based models, such as CODASYL, and include verbs such as create, add_member, and traverse. The model also has database operators that help maintain data integrity. These are absolutely identical to the CODASYL network data model and have the verbs begin, commit, abort, and checkpoint. ODMG attempts to recognize the importance of coexistence with relational databases, and the ODMG model is called a superset of the relational database model. The ODMG authors state: An important difference between the relational model and the ODMG object model is that the relational model does not support user-defined subtyping of the type hierarchy. Only built-in types can be used by applications. An object programmer must translate objects into the predefined structures supported by the relational DBMS in order to use the relational DBMS for persistent storage. Only the predefined, tableoriented operations supplied by SQL can be used to access the relational database. By contrast, the ODMG object model provides a way for application semantics to be expressed explicitly in the schema and supported directly by the OODBMS. (Loomis, 1993)
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduct
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/548-551.html (3 of 3)4/03/2005 6:16:51
Oracle Databases on the Web:The Future Of Database Management
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
The Future Of Hypermedia In Database Management Hypermedia has become a very popular term within the arena of database systems. Many PC-based systems and products advertise themselves as “hypermedia,” but a comparison of these products shows that they have very little in common. In basic terms, hypermedia refers to the ability of the database to incorporate audio and video information. From a database perspective, this audio and video information is simply other sources, or media. Many databases already allow for the inclusion of graphical images, and even mainframe databases allow for Binary Large Object (BLOB) datatypes. The latest craze within PC-based systems is the inclusion of WAV files. These files consist of binary audio information and always have the .WAV suffix, such as HORN. WAV. These files create predetermined sound effects and can be triggered by events within the system. For example, Microsoft Windows uses video-clip files, which allow for the inclusion of moving videos within the database. Many flashy database systems have been created by the addition of audio and video, and Microsoft corporation implements OLE (pronounced Oh-Lay), which refers to their Object Linking and Embedding technology. From a database perspective, these new forms of information are not a problem for the database designer. Sound effects and moving images are stored in the database and
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/551-554.html (1 of 3)4/03/2005 6:16:52
Oracle Databases on the Web:The Future Of Database Management
retrieved on request, just like conventional information. The problem with hypermedia lies in the effective design and presentation of the hypermedia information. Microsoft’s OLE allows divergent media to be incorporated into a single application. OLE runs under Microsoft Windows and allows a user to bundle audio, video, and graphics from any source in the Windows domain. Hyper in the phrase hypermedia system refers to the ability of the system to allow links, or calls, to other components within the system that contain ancillary information. These hyperlinks are commonly used within the Windows environment and allow the user of the system to dynamically move to other areas of interest. This concept is analogous to the See also references within encyclopedias. Some text-based databases, such as the Folio database, allow for linking between textual items. The real problem with the development of hypermedia systems is the presentation style of the system. Many vendors create hypermedia shells that allow database designers to add hypertext links to their applications, and it is very simple for a novice to create a system that takes advantage of sound and video. Unfortunately, many of these systems suffer from an artistic overload. Data processing professionals often have trouble with the feel for the dynamics of an effective presentation system, and the delivered products are often “noisy” and distracting. Today, the development of hypermedia systems should be done by professional choreographers who use design techniques more familiar to advertising professionals than computer programmers. This has major implications for the future of database systems design. The tools for the presentation of material are now so sophisticated that anyone can develop a hypermedia system, but not everyone can create an effective user interface. In many areas of database design, a feel for artistic design and graphics presentation will be more important than technical skills.
A Return To Centralized Data As corporations begin to realize that widespread distribution of their data resources can cause severe problems, there will be a movement toward the data warehouse concept (see Figure 18.2). Just as we saw a movement towards centralized data repositories in the 1970s, we are now seeing the same type of movement as a result of the failure of distributed data mechanisms to provide a simple solution to corporatewide data. This is not a condemnation of the replication tools within Oracle databases but simply a backlash against the inherent complexity involved when distributing data across multiple physical locations.
Figure 18.2 The return to centralized databases. From a data management viewpoint, the same problems that led to the invention of the first commercial databases are now returning. Thirty years ago, the industry was in the age of departmental computing, whereby each area within an organization had its own
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/551-554.html (2 of 3)4/03/2005 6:16:52
Oracle Databases on the Web:The Future Of Database Management
data processing staff, its own systems, and worst of all, its own data and data structures. This lack of data sharing is now returning as more departments are abandoning the mainframe and developing their own systems on PC platforms or midrange computers. You should remember that the impetus behind downsizing is primarily monetary. There is no reason to migrate from a mainframe to smaller systems except for the cheaper MIPS available on the smaller machines. Unfortunately, many companies are not only distributing their processing, they are distributing their data, often with disastrous results. As more and more companies learn that distributing their data can cause problems at the corporate level, we will see a move toward the recentralization of data. This doesn’t mean a return to the mainframe as we know it; it means that very large amounts of data will be managed and distributed to all platforms within a company.
Previous Table of Contents Next
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/551-554.html (3 of 3)4/03/2005 6:16:52
Oracle Databases on the Web:The Future Of Database Management
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Experiential Databases As the cost of computer hardware continues to fall, data processing will undergo another revolution. Just as the first supercomputers went unnoticed by mainstream computer professionals, the new hardware technology will emerge with a whisper. However, the implications toward the way people think about databases will change dramatically. Peripheral sensors have been developed that are far superior to human peripherals, but cognitive development lags far behind. We have cameras that can read a newspaper headline from outer space and ears that can hear far better than our own, but we have never mastered the cognitive ability of even the most primitive animal. Every second, the human mind processes thousands of bits of information. We perceive the distant humming of fluorescent light bulbs, the pressure of our bodies against our chairs, and many other perceptions unnoticed by our conscious mind. Numerous researchers in human cognition hypothesize that the human mind never forgets; what is lost when a memory is forgotten is the ability to recall the data and not the data itself. Oliver Sacks, the famous brain surgeon portrayed in the movie Awakenings, related a story in his fascinating book, The Man Who Mistook His Wife For A Hat. Doctor Sacks was performing brain surgery on a conscious patient when stimulation to a specific area of the brain caused the patient to remember a long forgotten incident. Remembering is not really an appropriate term, because the patient relived the incident and described a scene from her childhood in such detail that she could sing along with a tune playing on the Victrola.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/554-556.html (1 of 3)4/03/2005 6:16:53
Oracle Databases on the Web:The Future Of Database Management
When computers advance to the point where storage capacity approaches the capacity of the human mind, there will be a movement toward experiential database machines. Experiential machines will perceive the world around them and process information in a similar fashion to the human mind. Computers have long been able to learn from experience. Early database experiments in the 1960s demonstrated that a naive computer could learn the rules to simple games by playing the game with another computer. However, human reasoning often differs from computer reasoning—often in very fundamental ways. An excellent example happened during World War II when the allied forces were planning bombing raids on Germany. Attempts at bombing targets in Germany had proved disastrous, with well over onehalf of the aircraft lost. A primitive computer was engaged to solve the problem of delivering the maximum bomb load while minimizing the amount of lives lost. The computer was able to prove that less lives would be lost if a smaller number of planes were sent on the missions. Each of these planes would carry double the bomb load and just enough fuel to reach their target. After dropping their bombs, the crew would bail out and take their chances within Axis territory. Assume, for the point of this argument, that the statistical conclusion was correct, and that less lives would be lost if these one-way trips were adopted. The members in the Eighth Air Force were somewhat less than elated with this proposed solution, and elected to ignore the study. The idea of drawing straws for oneway trips to Germany was abhorrent to the crew members, even though they had a much higher probability of survival. Ultimately, the air crews decided to ignore the study, and hundreds of American lives were lost as a direct result of “irrational” human cognition. An experiential system needs to be able to perceive and act upon stimuli in the world. In order to do so, a model would need to be developed that would allow the database to retain information in a similar fashion to the human mind. Sigmund Freud postulated that human memory is persistent. All memories are retained within the brain, but most are inaccessible. These inaccessible, or unconscious, memories and experiences are nonetheless present and serve to guide the decision-making abilities of the human organism. Other psychologists have postulated that the human mind has very little ability to address detailed memory, and the human mind filters out unneeded stimuli, storing only what is required for the organism. This filtering mechanism is activated by priorities set by the conscious mind. For example, a pessimist chooses to ignore positive stimuli and instead focuses on the bad events of the day. Emotional reactions also govern what is stored in the mind. The human mind represses, or blocks, events that are unacceptable to the conscious mind, and would therefore interrupt the functioning of the organism. These types of filtering devices will need to be incorporated into the database memory processors, and a great deal will be learned about the relationship between human and computer cognition.
Previous Table of Contents Next
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/554-556.html (2 of 3)4/03/2005 6:16:53
Oracle Databases on the Web:The Future Of Database Management
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/554-556.html (3 of 3)4/03/2005 6:16:53
Oracle Databases on the Web:The Future Of Database Management
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Previous Table of Contents Next
Please Select
Voice Recognition Database Access Recognizing a human voice is one of the first things a baby learns, but it’s a very complex skill for a computer to learn. To create a system with voice recognition, a method needs to be devised that will allow voice access to database managers. Unfortunately, computers have had dismal results when learning to parse and understand human English. It is relatively simple to digitize sound waves for processing by a computer, but it is very difficult to get a computer to partition the sounds into words and to recognize where words begin and end. For example, computers have a hard time recognizing that bus station is two words because the sounds run together when they are spoken. Another problem with voice recognition is context-sensitive grammar. Even a child understands what it means when someone says, “Mary had a little lamb.” A computer, on the other hand, will be unable to resolve the verb had. What do you mean Mary had a little lamb? Did she buy the lamb? Did she eat the lamb? Exactly how did she have this lamb? Determining the context of spoken English has been a difficult, but not insurmountable task. Technology has progressed to the point where computers can isolate individual spoken words and can spell the words according to their context, such as “please write to Mr. Wright, right now.” After the spoken words and their individual meanings have been determined, the next step is to derive the meaning from the sentence. Nonstructured access to databases has
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/556-558.html (1 of 3)4/03/2005 6:16:54
Oracle Databases on the Web:The Future Of Database Management
long been of interest to researchers, and several products have come to the marketplace. Computer Associates markets a product called Online English, which claims to allow nonstructured queries against their IDMS database product. Other vendors have created tools that allow macros for the classification of database queries. For example, a user could state, “All salesmen who have not sold 3,000 products this month are turkeys.” This establishes a condition set for the word turkey, and a subsequent query, “Show me the turkeys,” will produce a list of salesmen who have sold less than 3,000 birds. Some of this research deals with the translation of English into foreign languages. A tool was built that translates English into Russian, and a reverse component was designed to translate Russian into English. The individual components worked relatively well when presented with well-structured sentences, but more obtuse sentences produces humorous results. For example, the phrase The spirit is willing but the flesh is weak, was translated into Russian, and then back into English. When the translation was complete, the phrase said, The vodka is good, but the meat is rotten. Savvy, a database query product by Excalibur corporation, performs in the same fashion. For example, an employee database could be queried with the statement, “How long has Joe been with us?” Savvy will respond by stating, “Are you asking for Joe’s date of birth, or Joe’s date of hire?” West publishing company has recently released a tool called Natural, which provides nonstructured queries against its vast legal database. West claims that the researcher only needs to state a general concept, and Natural will create a structured query on behalf of the user, returning the desired information. Query By Example (QBE) is a database retrieval tool by IBM that allows users to query their tables without learning SQL. Users of the DB2 database are presented with a list of database fields that they can combine to create “sample” tables that contain all of the columns and rows they desire. The user could also specify selection constraints. QBE will generate the appropriate SQL for the use and return of their query in a tabular format. Despite the primitive state of today’s technology, the next 30 years will see a revolution in ad hoc database access. Tools will be devised allowing users to state a query to an intelligent front end that will parse the meaning from the statement and return the results.
Summary While this chapter may seem futuristic, many of the topics discussed will soon become commonplace within the world of database management. It remains to be seen how soon the technology will be changing, but if the current trends in hardware technology continue, it will not be uncommon to see desktop computers with enough hardware resources to make artificial intelligence a reality.
Previous Table of Contents Next
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/556-558.html (2 of 3)4/03/2005 6:16:54
Oracle Databases on the Web:The Future Of Database Management
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/ch18/556-558.html (3 of 3)4/03/2005 6:16:54
Oracle Databases on the Web:Index
Click Here! Click Here!
ITKnowledge
home
account info
subscribe
login
search
FAQ/ site help map
contact us
To access the contents, click the chapter and section titles.
Oracle Databases on the Web Go! Keyword Brief Full Advanced Search Search Tips
(Publisher: The Coriolis Group) Author(s): Robert Papaj and Donald K. Burleson ISBN: 1576100995 Publication Date: 02/01/97 Search this book: Go!
Table of Contents
Please Select
Index A Abstract data typing. See ADT. Abstraction, 20, 547 Access privileges types, 346 Adding redundancy issues, 461 Adobe PageMill, 46 ADT, 18, 395 Advanced Research Projects Administration Network. See ARPANET. Amigo, 394 Analysis top-down, 138 traditional systems vs. Web-page systems, 138 API, 5, 36, 160, 389, 402 AppleScript, 153, 154 Applets, 41, 391, 402, 403, 406 Application developers, cardinal rule, 144 front-ends, designing, 137 object-oriented, 26 protocol interfaces. See APIs. standalone, 5
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (1 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
Archie, 5 ARPANET, 1 Array, 539 associative, 307 Audio, 46, 155 Audit script, using, 368
B Basic, 24 Basic Mapping System. See BMS. Behaviors, 396 Berners-Lee, Tim, 7 BIF, 291 Bill-of-Materials explosion, 466 relationships. See BOM relationships. Binary Large Object. See BLOB. Bitmap. See BMP. Black box, 26 BLOB, 551 BMP, 60 BMS, 137 Body procedures, 166 BOM relationships, 466 Bourne shell, 153. See also CGI scripts. Browser display, 127 Built-in functions. See BIF. Burleson, Donald K., 438 Bush, Vannevar, 6
C C, 154 C or C++, 153 C programming languages, 394 C++, 15, 42, 154, 392, 547. See also Languages, object-oriented. vs. Java, 395 Caillian, Robert, 7 Cartesian product, 543 Cartridge, 35 Cattributes, 45 CERN, 7 CGI, 33, 34, 36, 112, 151, 278, 405, 420, 441, 503 components, 152–59 origins, 151–52 programming, common use, 153 languages, 153 programs vs. CGI scripts, 154 scripts, 154, 159, 423 file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (2 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
vs. WRB, 159 Character format procedures, 169 Check constraint, 494 Checkboxes, 64, 332 Claris, 46 Class, 396 definition vs. interface definition, 400 Clickable image maps, 135, 152 Client/server, 5, 439 application, 120 architecture, 465 environment, 520 interfaces, 490 paradigm, 120 and parallelism, 497–500 processing, 120 running Java on, 402 Clones access, 122 Cluster, 519 COBOL, 14, 293 CODASYL, 15, 550 Codd, Dr. E. F., 458, 474. See also Rules of normalization. Code reusability, 395 Coherent operating system, 447 Common Gateway Interface. See CGI. Community, 439 Compiled programs vs. interpretive CGI scripts, 154 Computer Associates, 556 Concatenated index guidelines, 495 Concurrency control, 489 management, 378 Connect strings, 443 Connection client-to-server, 11 ConQuest, 118, 547 Constraints, 482 Contention, 386 Context Level DFD, 138 Cookies, 121, 251 definition, 121 expiring, 253 file, 252 Copyright, 137 Corruption, logical, 386 Cost-based optimizer. See Optimizer. Cron, 437 Crontab, 334 Cross-database access, 436 file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (3 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
C-shell, 147, 153, 426, 429. See also CGI scripts. Cursors types, 542 Customer ID, 127 Cyberspace domain, 143
D Data flow diagram. See DFD. Data items, 396 Data Manipulation Language. See DML. Data redundancy, 458 Data relationships many-to-many, 465–66, 519 one-to-many, 327, 460–65, 519 recursive, 466–69 types, 457 Data warehouse concept, 552 Database Administration. See DBA. Database Connection Descriptors. See DCD. Database data, 46 deadlock, 382, 385, 386, 490 experiential, 554–56 integrity, maintaining, 387 link, 432, 445, 446 locking, 382 object-oriented, 15 redundancy, 459 relationships. See Data relationships. DB2, 487, 533 DBA, 19, 20, 346, 361, 390, 547 DCD, 104, 405 Deadly embrace, 382 DEC Alpha, 395 Declare section, 292 Denotable objects, 549 Design issues major, 142 Designer 2000, 28, 548 Designer 2001, 28, 548 Developer 2000, 121 DFD, 138, 139, 140 Diagram task-flow, 141 Dictionary update running, 106 Directory list, 178 Dirty reads, 379 Displacement, 526 Distributed data file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (4 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
management, 12 Distributed request, 444 Distribution, 485 DML, 15 Domain, 435 Domain name, 9 Domain Name Services, 4 Dynamic page generation, 133
E E/R model, 460, 463, 464, 465, 468, 470, 548 Effective role development guidelines, 358 Efficient SQL general tips, 528–30 Email, 5 Encapsulating code benefits, 362 Encapsulation, 26, 396, 547 vs. SQL, 27 Enquire-Within-Upon-Everything, 7 Entity/Relation model. See E/R model. Environment variables, 154 Error page generic, 323 Error statuses, 321 European Particle Physics Institute, 7 Excalibur Corporation, 557 Executables, 74, 75 Existing process, 449 Explain plan, 530 Explicit cursors, 542
F File Transfer Protocol. See FTP. Focus, 14 Folio, 118, 547 Fonts and different platforms, 122 foreign keys, redundant, 458 Form, 157, 158, 326 procedures, 169 vs. traditional online screen, 326 Fortran, 14, 153, 154 Fragments, 507 Frame, 11, 127, 167, 207 definition, 127 procedures, 167 Freud, Sigmund, 555 file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (5 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
FTP, 3, 5 Fulcrum, 118, 547 Full-table scans, 484, 491, 496, 518, 522, 526, 527, 539 Functional partitioning, 436 Functions, 349
G Gallium Arsenide, 15 General Interface Format. See GIF. Generalization, 28 GIF, 59, 60, 135, 337 GMT, 254, 255, 423 Gopher, 5 Gosling, James, 392 Grant privileges, cascading, 350 Graphical user interface. See GUI. GreenOS, 392 Greenwich Mean Time. See GMT. See also Time zones. GUI, 6, 8, 12, 125, 337
H Hash cluster, 517 Hashing, 516–19 Hashing algorithm, 517 Head procedures, 165 Help page, 144 Henrich, Charles, 152 High-speed phonelines, 2 Hint, 461 Holos, 547 Home Locator, 88 format, 79 Home page, 8 Horizontal partitioning, 435, 436 Hostname, 9 and domain name, 9 HotJava, 393 Hotspots, 158 HP-UX, 439 HTML, 7, 9, 11, 46, 155 basics, 46–48 official standards, 38 operations, 120 viewing source code, 64 HTP/HTF Parameters, 171 HTTP, 7, 8, 10, 11, 76, 77, 102, 112 HyperCard, 7 Hyperlinks, 46, 130–32
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (6 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
Hypermedia, 8 future, 551–52 Hypertext, 6 Hypertext Markup Language. See HTML. Hypertext Transfer Protocol. See HTTP.
I IBM’s IMS database, 15 Image, 155 Image map, 67, 157, 174, 213, 223, 337, 402 creation, 190–92 management, 253 Implicit cursor, 542 Indexes. See also Concatenated index. concatenated, 488 and constraints, 493–94 guidelines, 486 multicolumn, 494 and Oracle performance, 496 tuning queries, 486–88 Inheritance, 21, 22, 395, 396 multiple, 21 Installation process, 72 Installer prompts, 78 Intel 486, 395 Interface definition vs. class definition, 400 Interfaces, 400 Internet, 1, 504 address, 3 applications, 2, 5 communication protocols, 2 components, 2 cost of connecting, 2 physical network, 2 vs. World Wide Web, 6 Internet Explorer, 71, 120 Internet Network Information Center. See InterNIC. Internet Protocol. See IP. Internet-based online systems, 12 future, 12 InterNIC, 4 Interscreen travel methods, 336 Intersystem connectivity, 436 Intranets, 8 Invoke, 375 IP, 3, 433, 442, 443 ISA relationship, 29, 548
J file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (7 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
Java, 34, 41, 112, 118, 391–92, 542, 543 benefits of using, 42 creating dynamic HTML documents, 415 development, 392–93 error messages, 411 HTML examples, 416–19 object-orientation, 395–97 performance, 398 portability, 393–95 security, 397 vs. C++, 42, 395 vs. PL/SQL, 404 wrapper, 412 Java Cartridge, 33 Java Code fundamentals, 398–401 Java Interpreter, 41, 43, 401, 402, 404, 405 Java Virtual Machine, 393–94, 403 Java Web Toolkit, 43, 404, 405 JavaScript, 404 JDK, 411 Joint Photographic Experts Group. See JPEG. JPEG, 59, 60, 135, 337
K Kimball, Dr. Ralph, 468 Korn shell, 153, 334, 372. See also CGI scripts.
L Languages declarative, 526 object-oriented, 13, 23, 24, 25, 36, 45, 301, 302, 541 procedural, 291, 541 LAN, 11 LaTeX, 11 Link, 46, 376 references, 59 Linux, 394 List procedures, 168 Listener commands, 449 processes, 112, 452 LiveHTML, 34, 118, 419–29 cartridge, 33, 43 examples, 423–29 Interpreter, 401, 420 similarity to SGML, 421
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (8 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
syntax, 421–23 Local area networks. See LAN. Local mode, 382 Location transparency, 4, 432, 446 Lock chain, 385 Lock escalation, 384 Lock pool resources, 386 Locking, 489 solution, 379 Locks exclusive, 381 shared, 381 table-level, 385 Logging features, 145 Logical volume manager. See LVM. LVM, 520, 521
M MacOS, 394 Mailto protocol, 222 Managing Distributed Databases, 438 MAP files, formatting, 158 Massively parallel processors. See MPP. Master lookup table, 438 McCool, Rob, 152 Memory fencing. See Pinning. Message, 25 MetaCube, 547 Method, 396 coexistence, 381 Microsoft, 549 Access, 14 Internet Explorer, 11, 64 Visual Basic, 14 Windows, 6, 468, 551 and design issues, 124 MIME, 155, 278 types, 156 Mode conversational, 378, 382 pseudo-conversational, 378, 382 Model object-oriented, 16 Morphology, 547 Mosaic, 393 MPP, 500 MS Query, 373 MTS, 439, 440, 449, 450, 451 starting rules of thumb, 451 Multiprocessing, 497 file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (9 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
Multipurpose Internet Mail Extension. See MIME. Multitasking, 497 Multithreaded server. See MTS. Multithreading, 497
N Names facility, 446 National Center for Supercomputing Applications. See NCSA. National Language Support. See NLS. National Science Foundation, 2 Natural, 557 Natural language, 547 Navigation pathway complexity, 142 NCSA, 152 HTTPd, 36 Nelson, Ted, 6 Netscape, 11, 54, 64, 71, 94, 101, 120, 122, 124, 129, 135, 152, 251, 393 communications server, 36 and frames, 128 Network Computers and Java technology, 402 Network host, 11 Network Programmatic Interface. See NPI. NeXT, 7 NFSNET, 1 NIC, 4 NLS, 81, 89 Nobody, 86, 161 NPI, 441
O O2 technology, 549 Object administrator functions, 20 consolidator, 546 Data Management Group. See ODMG. Design, 549 identifier. See OID. Linking and Embedding. See OLE. Management Group. See OMG. privileges, 348 Request Broker. See ORB. technology, 12 Object-oriented approach, 547 database standard architecture, 549 databases, 545 languages. See Languages, object-oriented. paradigm, 22 file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (10 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
programming. See OOP. Objects aggregate, 19 and behaviors, associations, 17 ODMG, 18 ODMG Object Model, 548–51 OFA, 78 OID, 549 OLAP, 471 OLE, 551, 552 OMG, 18 Online English, 556 systems design, 138 video clips. See VID files. Ontos, 549 OODB, 548 OOP, 396 Open systems, 344 OPI, 441 OPS$, 446, 451 Optimal Flexible Architecture. See OFA. Optimizer cost-based, 458, 485, 491, 496, 521, 525, 537, 538, 539–40 rule-based, 458, 485, 496, 525, 526, 528, 535–39, 540 rule-based vs. cost-based, 539 Oracle7 database products, 72 Oracle8, 18, 19, 20, 27, 545–548 object layer, 18 Oracle bulletin #105025.433, 350 ConText, 546 database, 338 DBA, 297 Express, 547 and printing or downloading, 118 Programmatic Interface. See OPI. Sedona, 546 System ID. See SID. System Identifier, 73 table, 288 Web Administrative Server. See OWAS. Web Agent. See OWA. See also PL/SQL Agent. Web Agent DBA. See OWA_DBA. Web Listener. See OWL. Oracle Magazine’s home page, 64 Oracle RDBMS Database Administrator’s Guide, 537 Oracle WebServer, 133 3.0, log server, 148 installation, 76 file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (11 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
Installer, 74–76 uninstalling, 76, 85 Oraperl, 153, 154. See also CGI scripts. orasrv, 440. See also SQL*Net, listener process. ORB, 546 OS/2, 394, 497 Overloading, 24 OWA, 34, 77, 159, 338, 404 OWAS, 77, 100, 102 OWA_DBA, 95, 96, 97, 99, 104, 105 OWL, 33, 77, 85, 100, 155, 160, 403, 404, 504
P Package, 298, 349, 506, 508 wrapper, 406 Packets, 3 Pages framing, 174 levels, 142 Parallel query, 519–22 using, 500–502 Parallelism, 498, 499, 522. See also Client/server, parallelism. Partitioning, 180, 499, 520 Pattern, 268 Pellow, Nick, 7 People costs vs. CPU costs, 13 Perl, 112, 153, 154, 542, 543. See also CGI scripts. Persistence, 160 Personal Function,130, 131 Physical format procedures, 169 Pictures, 46 PID, 450 Pinging, 94, 100 Pinning, 507 automatic, 509 measuring packages, 509 PL/SQL, 41, 112, 134, 160, 291, 397, 412 problems, 299, 542 syntax structures, 292 tuning, 299–301, 541–44 PL/SQL Agent, 34, 36, 37, 159, 401, 403, 405, 504 Developer’s Toolkit, 107 packages, 408 procedure, 112, 114, 154 role, 38 stored procedure, 37 vs. Java Interpreter, 41 vs. Java Interpreter, 41 PL/SQL User’s Guide and Reference, 324 PL/SQL Web Toolkit file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (12 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
and Java Web Toolkit, 404 Plain text, 155 Point-to-point lines, 2 Polymorphism, 23, 24, 25, 395, 547 Pop-up list, 63, 333 PowerBuilder, 118, 119, 126 Preemptive locks. See Locks, exclusive. Pre-spawned shadow. See Existing process. “Primacy of the user” principle, 145 Print procedures, 165 Prism, 497 Privileges combining, 350 object vs. system, 347 Pro*C, 450 Procedural Language/Structured Query Language. See PL/SQL. Procedures and packages problem, 349 Process ID. See PID. Processing improving speeds, 478 pseudo-conversational, 144 SMP vs. MPP, 500 Programming object-oriented, 15 profession, 15 Protocols, 2 application, 3 levels, 3 network, 3 transport, 3 Providing OLAP (Online Analytical Processing) to User-Analysts: An IT Mandate, 458 Public synonym, creating, 109
Q Query By Example, 557 See QBE.
R Radio buttons, 63, 333 RAID, 520, 521 Referential Integrity. See RI. Remote client, speed, 121 connection, 444 request, 444 Requests servicing, 112 Results file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (13 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
non-reproducible, 382 RI, 482, 483, 486, 494 Roles, 345, 352, 355 creating, 361 Ronco, 23 Router, 11 Row information updating, 339–44 Rows phantom, 382 RTF, 11 Rule-based optimizer. See Optimizer, rule-based. Rules of normalization, 458, 474
S Sacks, Oliver, 554 Sanders, Tony, 152 Sargeable predicate, 486, 489 SAS, 14 Savvy, 557 Screen layout creation, 137 Screen transfer vs. hyperlinks, 130 Screen moving in WebServer, 376 transfer, 375 SDK, 125 Security, 344 achieving simplicity, 365 checks, 345 data-specific vs. application-specific, 361–63 in remote database, 355 starting guidelines, 373–74 stored procedure vs. role-based, 349 two methods for managing, 346 Selectivity, 485 Sequential pre-fetch, 487 Server Side Includes. See SSI. See also LiveHTML. ServerManager, 281 Service lines, 2 Service names, 443 SGA, 298, 506, 507, 509, 512 SGML, 11, 47, 420 Short On Storage. See SOS. SID, 407, 439, 442 Slow image display, problems, 120 SmallTalk, 15, 547. See also Languages, object-oriented. SMP, 500, 521 Snapshots, 474–82 complete refresh, 475 creating, 475 file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (14 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
fast refresh, 475 Software Asset Manager, 83–84, 91 Solaris, 394 space required, 74 Solaris Unix, 439 SOS, 381 Spawned, 450 SQL, 15, 20, 27 SQL cursors types, 299 SQL*DBA, 281 SQL*Forms, 118, 119, 121, 126, 130, 299, 312, 319, 327, 337, 341, 450, 483, 541 SQL*Net, 432, 436, 438–50, 478, 501, 505 1.0 vs. 2.0, 440 connection error message, 445 connections to remote databases, 443 connections types, 456 listener process, 447 ways to establish database communications, 444 SQL*Net Sessions viewing, 454–56 SQL*Plus, 27, 281, 354, 373, 445, 447, 454, 513 SSI, 43, 402, 420 Standard Generalized Markup Language. See SGML. Star schema design, 465–468 State, 396 Stored procedure, 297, 349, 356, 357, 377, 435, 441, 505, 508, 512 access, testing, 110 benefits, 505 Striping, 521 Structure procedures, 165 Structured Query Language. See SQL. Sun Microsystems, 392 SunSoft, 549 Symmetrical multiprocessing. See SMP. Synonyms, 353–54 System Global Area. See SGA. System privileges, 346, 347 Systems analysis purpose, 140 Systems design process purpose, 141
T Table, 129 HTML vs. Oracle, 243 partial replication, 481 privileges, 346 procedures, 170 file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (15 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
replication, 436, 474 Table-level security, 356 replacing, 360 Tags, 47 Target string, 256 Task-flow diagram, 141 TCL, 153, 154. See also CGI scripts. TCP, 3 TCP/IP, 3, 101, 439, 443 Technical support, 115 Telnet, 5 Temporary tables using, 534–35 Text, 46 alignment, 124 highlighting, 235 Thrashing, 506 TIFF, 60 Time zones, 255 Time-Warner, 393 TNS, 433, 435 TNS listener, 440 tnslsnr, 440. See also SQL*Net, listener process. Trace facility, 533 Tracking error messages, 146 Tranparent network substrate. See TNS. Transaction freezing, 144 global, 432 Transfer, 376 Transmission Control Protocol. See TCP. Triggers, 297, 350, 481, 505, 515 vs. stored procedures, 516 when to use, 516 2PC, 389, 453–54 Two-phase commit. See 2PC.
U UDP, 3 Uniform Resource Locator. See URL. Universal object manager, 546 Unix, 5, 424 documentation screen, 83 Updatable snapshots, 474 Update procedure, 303 UPI, 440, 441 URL, 8, 59, 85, 112, 280 components, 9 format, 9 User Datagram Protocol. See UDP. file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (16 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
User Programmatic Interface. See UPI.
V Versant, 549 Vertical partition, 432, 436 VID files, 120 Video, 46, 155 Views, 357 Virtual reality environments. See VRML. Visual Basic, 153 Voice Recognition Database Access, 556–57 VRML, 120
W WAIS, 3, 5 WAN, 1, 2 Web listener, 32, 33, 34, 35, 190 Web page constructs, 46 definition, 46 vs. SQL*Form or PowerBuilder, 126, 319 Web Request Broker. See WRB. Web technology, 8 Web Transaction Manager, 43–44 WebMaster, 161 WebServer, 29, 38–39, 312 3.0, 121 Administrative Server, default port, 92 applications, 118–19 basic components, 33 configuring WebServer 1, 94–100 configuring WebServer 2, 100–05 differences between versions 1 and 2, 34 installing WebServer 1, 76–85 installing WebServer 2, 85–93 primary purpose, 32 real benefit, 41 using, 71 West Publishing Company, 557 Whitney, Eli, 13 Wide-Area Information Servers. See WAIS. Wide-area network. See WAN. Widgets, 125, 126 Wildcards, extensions, 257 Windows, 394 Windows NT, 497 Windows Standard Development Kit. See SDK. Wizards, 15 World Wide Web, 6, 12 file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (17 of 18)4/03/2005 6:19:55
Oracle Databases on the Web:Index
elements, 8 origin, 7 principles, 7 Wrappers, 405 WRB, 33, 34, 36, 85, 112, 151, 159, 160, 278, 378, 401, 402, 403, 404, 405, 420, 441, 448, 503, 504 executable engine. See WRBX. services, 86 vs. CGI, 35, 112, 161 WRBX, 36, 85 WWW, 5
Z Zone names, 9
Table of Contents
Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject
file:///F|/My%20Bookcase/Database/Oracle/Oracle%20Databases%20On%20The%20Web/book-index.html (18 of 18)4/03/2005 6:19:55