Académique Documents
Professionnel Documents
Culture Documents
Overview------------------------------------------------------------------------------------------------------ 9
Synopsis-----------------------------------------------------------------------------------------------------18
History--------------------------------------------------------------------------------------------------------18
Conclusion--------------------------------------------------------------------------------------------------20
A n a ly s is a n d de s ig n D e v e lo p m e n t D ep lo ym e n t
M od elin g
C od ing
L o gical T u nin g
M od el M ain ten ance, C han ge M an agem ent
S e rver-side log ic
P h y sical (P L /S Q L )
M od el
E m b edd ed S Q L
Unfortunately, the state of tools for SQL tuning and PL/SQL development lags behind
more popular programming environments, with Oracle Corporation traditionally focused
more on applications and less on development tools. We provide our vision of the ideal
SQL Development Guidelines 1 White Paper
development tools required to implement our recommendations, and take a closer look
at the Unicenter SQL-Station suite.
We do not cover the topic of logical and physical database design since they are closer
to the analysis and design stages of application development than to the actual
implementation stages.
Training
Training is essential. Any organization planning to develop in Oracle’s PL/SQL must
have a good training program. PL/SQL is not self-explanatory or intuitive enough to let
programmers pick it up as they go — the consequences will be illiteracy in PL/SQL, a
20% – 40% utilization of the power of the language and poorly written code.
Programming Standards
Programming standards are as important as good training procedures. Creating and
enforcing coding standards with PL/SQL, as with any other programming language, will
ensure higher quality code that is easier to read, understand, maintain and reuse. The
set of standards suitable to a specific organization should include a mix of existing
coding practices, advice from experienced PL/SQL developers, good programming
practices recommended by industry-experts in PL/SQL and a library of existing and
reusable, best-in-class PL/SQL code objects gathered from throughout the organization.
The list of topics in the set of PL/SQL programming standards should include:
• Modularization and structured programming rules of thumb.
• Guidelines for using packages and persistent data.
• Documentation guidelines—location in the module, mandatory contents, style and so
on.
• Coding style and indentation rules.
• Upper/lower case usage rules.
• Naming conventions — for objects, variables, arguments, exceptions, constants and
so on.
• Variable naming, typing and declaration formatting rules (and do not forget to
discuss anchored data types).
• Coding SQL statements within PL/SQL.
• Templates and coding rules for all the recommended control structures (cursors, if
statements, loops and so on).
Dealing with database programming has some of its own specific requirements, and these should
not be ignored when evaluating tools. The ideal IDE should allow the developer to navigate the
database catalog, as the equivalent of the file system in conventional client-side environments,
and preferably support simultaneous access to multiple database servers in your distributed
environment. A developer should have access to catalog objects on the development environment
(test), but also to the production environment — especially in maintenance tasks as well as the file
Figure 3 — Query execution with friendly GUI and results display (Unicenter SQL-Station)
Debugging
When evaluating debugging facilities, using printf (or the PL/SQL equivalent—the
DBMS_OUTPUT package) should not be regarded as a feasible solution. Programming
tools in the 1990s allow developers to step through statements while debugging, set
breakpoints, view and modify variable values, automatically detect dependencies and so
on. Debugging can take as much as a third of the development phase; so expediting the
debugging process has a significant impact on application delivery, not to mention
quality.
Tuning
Performance problems in client/server applications are usually related to database
access and un-tuned SQL. The need to tune SQL statements is a facet of SQL
programming that is unique to database programming and not familiar in other
development environments. Therefore, a complete chapter is dedicated to this topic, so
essential to the success of client/server applications.
Overview
Database objects, including both data objects (tables, indexes and views) and code
objects (stored procedures and triggers) are an important element of a complete
client/server application. Very much like other application elements, these objects need
to be managed and controlled, and should follow the same rules of change and
configuration management as the rest of the application.
Traditional source control and configuration management tools do not address database
objects well. This section will present the major challenges related to managing and
controlling database objects, and suggests desired functions from an ideal software
package.
Current Methods
The source control tools normally available to DBAs and project managers are limited
and rudimentary. They do not follow familiar version control metaphors, nor do they take
advantage of information or supporting data available from the RDBMS itself, such as
the catalog.
Usually, DBAs will combine DDL commands for creating tables and indexes into long
and difficult to manage scripts. This can create significant difficulties, including the
following:
• Dependencies are difficult to manage.
• Minor changes in scripts can impact the whole database.
• Object codes (especially stored procedures) are not integrated in the scripts.
• After a change is performed, it is difficult to revert to a previous working version.
• Deploying from various test and deployment environments can prove extremely hard
to manage.
In an ideal world, all the application entities should be centrally managed and controlled
in a repository to ensure proper control, quality and reliability. On top of the repository,
additional procedures, standards and supporting software tools will enable proper
sharing and reusability of code, enforcement of security, version control, definition of
fixes, releases and versions.
Deployment
Once development and testing of the application/enhancements or fixes are completed,
the deployment of the new entities should be automatic and self-contained. The first step
in deployment is defining the deployment unit. The deployment unit is a project or sub-
Dependency Analysis
Unlike the application world, database objects usually have complex inter-relationships,
imposing a certain order in the deployment process. For example, a table referring to
another table (such as foreign key) cannot be defined before the other table is defined.
The dependency analysis can prove to be tricky and time-consuming, therefore
automatic dependency analysis is very useful in the deployment process to ensure
successful object deployment in the correct order.
Select from
Capture on Repository
source
Server
SQL
Explain Get run-
plan time
statistics
Analyze
objects Hints
The Explain plan is rather cryptic — to decipher and really understand it, one needs
significant experience and training. However, understanding the Explain plan is key to
being capable of tuning the statement and improving its performance. The better the tool
you have to understand the Explain plan, the easier it is to achieve the best optimization
SQL Development Guidelines 14 White Paper
possible. After understanding the optimization plan, it’s easy to pinpoint the problem
areas: full table scans, Cartesian joins and so on.
Figure 9 — Oracle’s Explain plan with a “little” help from Unicenter® SQL-Station® Plan
Analyzer® for Oracle
After the how, you will need to understand the why. For example, why did the optimizer choose to
ignore/use a specific index? In this stage, you will need to have access to concise information on
the objects referenced in the SQL: tables, views, indexes, clusters and their statistics. Be on the
watch for tables and indexes that have not been analyzed, indexes not being used or indexes that
are used but are useless (because of low selectivity ratio, for example).
As important as the previous steps — test it! Once the plan seems reasonable, run the statement
and gather all the statistics you can and make an assessment if it is still reasonable. And make
sure to test it in an environment similar to your deployment environment: donít run the SQL against
a table with 25 rows when the production table will have one million rows. The results are likely to
be slightly different.
One of the most powerful facilities provided by the Oracle engine is the ability to use
hints. Hints are the ultimate solution for forcing the optimizer to use an optimization
plan, different than the default that the developer finds or expects to perform better. For
example, force the usage of a specific index that has not been selected by the optimizer,
or force a specific type of join. Hints are extremely powerful and extremely delicate at the
same time, since they bypass the optimizer. The main challenge with hints is
understanding them and finding the one most appropriate to your statement. Oracle
adds new hints with every release, and it’s difficult to keep track of all of them. Another
Figure 10 — Adding Hints in sub queries (Unicenter® SQL-Station® Plan Analyzer® for
Oracle Hint Wizard)
With all this richness of options and solutions, the key is to be able to implement the statements
that perform best in your own specific environment. Again, having the right tools really makes a
difference. Performing all the steps mentioned above will require an unreasonable amount of
time using standard Oracle tools. Therefore, there is a high risk that these best practices will be
ignored in the rush to deliver the application on schedule.
Synopsis
Computer Associates International, Inc. (CA) is the industry leader in eBusiness
Database Management solutions. With Unicenter® SQL-Station® for Oracle, CA provides
the most complete and valuable offering in the marketplace for Oracle database
programmers.
Following is a brief description of the way in which those tools provide solutions to the
pains felt by organizations and individuals in the field of Oracle SQL and PL/SQL
programming.
History
CA with its vast expertise in databases, perceived the value and importance of tools for
database programming in the Oracle environment. As early as 1995, Computer
Associates decided to enter the market of tools for database server-side programming.
Conclusion
It has been estimated that 80% of database application performance issues are SQL
related. As companies are becoming more reliant upon their data assets, it is imperative
that data retrieval performance meets essential service levels. However, the initial
design and programming of the database code that performs the retrieval can be
complex, especially to those without expert SQL and or PL/SQL programming skills.
Once databases and applications are deployed in production, their code still has to be
managed and optimized.
The highly intuitive Graphical User Interface and Integrated Development Environment
provided by Unicenter SQL-Station streamlines complex day-to-day tasks in addition to
enabling easy adherence to programming standards and guidelines. Unicenter
SQL-Station is a solution no Database Developer should be without.
Information in this document is provided “AS IS” without warranty of any kind, and is subject to change without notice by
CA, which assumes no responsibility for any errors or claims herein.
© 2004 Computer Associates International, Inc. (CA). All trademarks, trade names, service marks and logos referenced
herein belong to their respective companies.