ORACLE DEVELOPER TOOLS FOR VISUAL STUDIO
ORACLE DEVELOPER TOOLS FOR VISUAL STUDIO
Time for a .NET Tune-Up
Tune your .NET application’s use of Oracle Database with Oracle Developer Tools for Visual Studio.
D clause in the query changing dynamically
eveloping a .NET and Oracle applica-
SYSDBA privileges to use Oracle Performance
with every loop. It then fetches all the data typical lifecycle. It includes many steps, such
tion in Microsoft Visual Studio follows a
Analyzer, and the HR user will need the
ADVISOR privilege to use SQL Tuning Advisor.
for each query.
as creating users and roles, assigning
Consider the large query created against privileges, creating tables and stored proce-
The application we will develop requires
the HR.EMPLOYEES, HR.DEPARTMENTS, dures, generating SQL scripts, writing .NET
two new tables based on the HR schema.
HR. EMPLOYEES2, and HR.DEPARTMENTS2 code with Oracle Data Provider for .NET
From Visual Studio, right-click the root
tables. Given that we’re still in the develop- (ODP.NET), and checking everything into
node of Server Explorer and create a new
ment phase without access to real-world pro- source control.
Oracle connection, as HR. Next, right-
duction data, how can we tell if that query will Another important phase of the develop-
click the HR connection and choose Query
perform well? Well, one way is to put it into ment lifecycle involves tuning your applica-
Window . In the query window that opens,
SQL Tuning Advisor and see what comes back. tion’s use of Oracle Database to maximize
enter create table employees2 as
Copy and paste the query from the code performance. Luckily, tools that enhance per-
select * from employees and click the
into the HR query window you opened earlier. formance are among the major new features
execute button (the green arrow in the query
The query in the .NET code is missing a value in Oracle Developer Tools for Visual Studio
window toolbar). Next, erase that statement,
at the end of the WHERE clause, so just add Release 11.1.0.7.20. Oracle Performance
enter create table departments2 as
the number 0 at the end. Your query should Analyzer analyzes your application’s use of
select * from departments , and again
execute the statement.
look like this:
Oracle Database under load and provides recommendations for resolving performance
select employees2.salary problems. SQL Tuning Advisor tunes SQL—
TUNING SQL
from employees2, departments2 both ad hoc SQL typed in at development
To follow along, download the Visual Studio
where employees2.department_id= time and SQL flagged by Oracle Performance
project associated with this article, available
departments2.department_id Analyzer as poorly performing. These tools
at otn.oracle.com/oramag/oracle/10-may/
and employees2.salary <3000 union leverage Oracle Database’s Automatic
o30odpodt.zip. Open the Visual Studio
select employees.salary Workload Repository (AWR) feature, which
project; you’ll see that the bulk of the code
from employees, departments captures database statistics, and Automatic
in the main source file (ReallyBadCode.cs) is
where employees.department_ Database Diagnostic Monitor (ADDM) feature,
shown in Listing 1. Take a close look at it. It
id=departments.department_id which analyzes these statistics and generates
creates a connection pool and then repeat-
and employees.salary =0; recommendations for fixing problems. In this article, we will use these tools to help us clean up a poorly performing applica- tion, aptly named ReallyBadCode.
edly executes a query, with the WHERE