I am transitioning into Oracle on RDS (should make it easier than Linux based!) from a SQL Server background and have a few queries;
- Index Maintenance. In SQL Server dependant on maintenance window I reorganise anything over x amount of rows with fragmentation > 10% but < 30%. Anything > 30% gets a rebuild. I can't seem to find any advice on this sort of thing in Oracle
- Integrity check. In SQL Server I do these often as possible, usually every 24 hours. Again struggling to find best practice for Oracle here. I've seen DBVERIFY mentioned but that's about it
- Statistics – I wont do routine maintenance on this (unless done via index rebuild) unless I find an issue. In SQL Server stats are automatically taken care of when a table grows by 500 rows + 20%, is there an Oracle equivalent?
- TABLESPACES – not so much of a maintenance issue, however I believe these are equivalent to databases files in SQL SErver which can grow in a similar fashion, I believe by "AutoExtend". However how do I set what percent or size a TABLESPACE should grow by? And also is it not better practice to presize these to avoid any growth during production hours?
- What are the best "DBA" and performance views to use? i.e. in SQL Server I will use sys.dm_exec_Requests or sp_who2 to see what is hitting the server, sys.dm_os_performance_counters to see performance counters and will log into the box to use perfmon for a graphic interface, what are the rough equivalents of this?
- On the above point, are the key metrics in Oracle the same as SQL Server, roughly? I.e. PLE, buffer hit cache, disk latency etc
Any other links or advice which will give me enough knowledge to "Keep the lights on" and know where to look if an issue arises would be greatly appreciated.
Best Answer
When to rebuild Indexes?
Index Internals- Rebuilding The Truth
DBVERIFY: Offline Database Verification Utility
DBMS_STATS
package. Details are given in the following white paper.Best Practices for Gathering Optimizer Statistics
How often we should gather statistics is depend upon how much changes are being made in the tables which affect the query plan. In other words when statistics become stale we need to gather statistics. You can set stale percentage threshold for a table using
STALE_PERCENT
(default is 10%) parameter ofSET_TABLE_PREFS
procedure underDBMS_STATS
package. For details:DBMS_STATS
AUTOEXTEND ON NEXT
clause either inCREATE TABLESPACE
orALTER TABLESPACE
statements.Auto extending doesn't affect the performance noticeably as it doesn't happen frequently unless we specify very small size on
NEXT
clause.CREATE TABLESPACE
V$SESSION
: Currently active sessions.V$SQL
: SQL command recently executed and its related information.V$SGA
: Statistics related to Oracle's shared memory called SGA.Dynamic Performance View Description
Generally speaking, these are same just Oracle has different terminologies to address them. For example, Page is equivalent to Data Block in Oracle and life expectancy of a block is determined by touch count algorithm similar to LRU(Least Frequently Used) algorithm.