The "top" SQL statements represent the SQL statements that are executed most often, that use more system resources than other SQL statements, or that use system resources more frequently than other SQL statements. Viewing the top SQL statements report that is available in the Oracle Database XE graphical user interface enables you to focus your SQL tuning efforts on the statements that can have the most impact on database performance.
But how do I clear the information currently held?
Try to flush the shared pool:
ALTER SYSTEM FLUSH SHARED_POOL;
Because the shared pool contains the SQL cache, cleaning it, also it's going to clear the other data.
Of course, be carefull because it also flush other useful data:
Cached data dictionary information and
Shared SQL and PL/SQL areas for SQL statements, stored procedures, function, packages, and triggers.
References:
ALTER SYSTEM - Oracle® Database SQL Language Reference 11g Release 2 (11.2)
Shared pool - Oracle® Database Concepts 11g Release 2 (11.2)
Related
As far as I know there is very little difference between the two except syntax. You have to use:
CALL METHOD for AMDP
CALL DATABASE PROCEDURE for HANA Procedure
Is the AMDP performance affected by the fact it is run at ABAP Application Server?
Can this architectural downside be overcome by the SQL optimizations when comparing to HANA proc? What is the best entity to use (AMDP or HANA proc) when dealing with complex queries with multiple WITH and JOIN?
AMDP is the abbreviation of ABAP Managed Database Procedure
As the name implies, these are still database procedures, but more easy to create, maintain and transport, as they are stored in the Dictionary.
If you look into the definition of one, you will immediately see that the body is written in sqlscript1, the language that SAP uses for HANA DB procedures. It will run on the database.
There is no performance difference. If you can write efficient DB procedures, you can write efficient AMDP.
How to make them faster
Create a PlanViz file, check where the time is spent. Most often the JOIN conditions can be improved, sometimes a field is missing, or it is performed on calculated fields.
or L, or R, but never in ABAP
How do I extract DDL, Stored Procedures (SP) and other database scripts from Sybase ASE.
Look into the ddlgen utility included with sybase, ususally found in the Sybase Central directory, or the $SYBASE/ASEP/bin. This should be able to generate scripts to create all of the database objects including user-defined datatypes (UDD), indexes, stored procedures, etc.
You can use sp_helptext to show the DDL.
I have a question about stored procedure sp_updatestats. My understanding is when upgrading from SQL Server 2000 to SQL Server 2008, we need to execute such procedure, but when upgrading from SQL Server 2005 to SQL Server 2008, there is no need to execute such stored procedure.
Is my understanding correct? Another question is why from 2000 to 2008 there is need to execute such stored procedure, any reference documents?
thanks in advance,
George
As per Randy Minder's answer, I've never done it.
You should have regular index and/or stats maintenance anyway. An index rebuild includes statistics anyway.
You may want to update stats more often though so you'd run sp_updatestats separately. For example, index rebuild as weekends, stats nightly.
Up to date statistics are extremely useful to the query optimiser.
This is not necessary, at least not in my experience. Just get into the habit of regularly rebuilding your indexes and your stats will be updated as well.
Someone here mentioned that We should avoid naming stored procedures in MS SQL server like sp_XXX
Because that taking addition time to SQL server while check does exist system sotred procedure named like that. Because all system stored procs are starting with sp_.
Now I wondering is that a case with Functions in MSSQL, Does naming functions like fn_ take additional time to SQL while looking for system functions ?
No, I don't think so.
Found the following thread:
http://bytes.com/topic/sql-server/answers/78872-udf-starting-fn_
No. To call a system-supplied [User Defined Function], you
need to use ::, so that is what SQL
Server looks for. All system-supplied
UDFs are table functions, as scalar
system functions are not UDFs at all.
Hope this helps
For functions it does not matter, however it is recommended to NOT use a prefix of sp_ for stored procedures as it defines a system stored procedure and may cause an extra lookup in the MASTER database.
As sp_ prefix is reserved for system
stored procedure and any stored
procedure which has sp_ prefix will
cause an extra lookup in MASTER
database. There is another point to
note that if a stored procedure uses
same name, in user database as system
stored procedure in master database,
the stored procedure in user database
will never get executed as SQL Server
will always look first in master
database and will execute that one
rather one in user database.
http://furrukhbaig.wordpress.com/2007/08/22/stored-procedures-factssheet/
http://msdn.microsoft.com/en-us/library/dd172115.aspx
Our organization has a lot of its essential data in a mainframe Adabas database. We have ODBC access to this data and from C# have queried/updated it successfully using ODBC/Natural "stored procedures".
What we'd like to be able to do now is to query a mainframe table from within SQL Server 2005 stored procs, dump the results into a table variable, massage it, and join the result with native SQL data as a result set.
The execution of the Natural proc from SQL works fine when we're just selecting it; however, when we insert the result into a table variable SQL seems to be starting a distributed transaction that in turn seems to be wreaking havoc with our connections.
Given that we're not performing updates, is it possible to turn off this DTC-escalation behavior?
Any tips on getting DTC set up properly to talk to DataDirect's (formerly Neon Systems) Shadow ODBC driver?
Check out SET REMOTE_PROC_TRANSACTIONS OFF which should disable it.
Or sp_serveroption to configure the linked server generally, not per batch.
Because you are writing on the MS SQL side, you start a transaction.
By default, it escalates whether it needs to or not.
Even though the table variable does not particapate in the transaction.
I've had similar issues before where the MS SQL side behaves differently based on if MS SQL writes, in a stored proc and other stuff. The most reliable way I found was to use dynamic SQL calls to my Sybase linked server...
The following code sets the "Enable Promotion of Distributed Transactions" for linked servers:
USE [master]
GO
EXEC master.dbo.sp_serveroption #server=N'REMOTE_SERVER', #optname=N'remote proc transaction promotion', #optvalue=N'false'
GO
This will allow you to insert the results of a linked server stored procedure call into a table variable.
I'm not sure about DTC, but DTSX (Integration Services) may be useful for moving the data. However, if you can simply query the data, you may want to look at adding a linked server for direct access. You could then just write a simple query to populate your table based on a select from the linked server's table.
That's true. As you might guess, the Natural procedures we want to call do lookups and calculations that we'd like to keep at that level if possible.