Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> The Admin's point of view on DB users best practices

The Admin's point of view on DB users best practices

From: Rick Denoire <100.17706_at_germanynet.de>
Date: Sat, 14 Feb 2004 15:20:56 +0100
Message-ID: <mras209smjn3g6ndo2o6119f5dhoo666t5@4ax.com>


Hello

I am preparing a small presentation offering DB users some assistance about "best practices" when using Oracle, and defining the general policy in the Admin scope. Most of the users are not specially proficient in SQL and are even completely ignorant about DB internals.

Well, I am not specially proficient in SQL either, but I would never do a "delete * from <table>".

These points come into my mind. You are invited to add yours (take a look at "still missing" below).

  1. Learn what is a cartesian product and how to avoid it
  2. Be aware of the two major access paths: FTS and indexed. For queries delivering a small subset of data from a large table, index access should be preferred.
  3. Create indexes based on the most frequently used predicate columns.
  4. When you create an index, confirm that it is actually being used in the query. Avoid access to an indexed column through a function, otherwise the index will be ignored.
  5. When doing a full refresh of materialized views, drop indexes first and recreate them afterwards, or make them unusuable and rebuild them after the insert is completed.
  6. Always do an "insert /*+ APPEND */ " into an empty table, perhaps in nologging mode.
  7. Do not delete large amounts of data from a table. Transfer data to be kept to another table instead, and rename as appropriate.
  8. If a fresh table or materialized view is created and populated, gather statistics immediately afterwards (the Admin will do it sure, but only later or on weekends).
  9. If a table or materialized view is recreated or repopulated with a similar amount of data, do not gather any statistics. Rather save statistics data from the table prior to the recreation and transfer them back again afterwards.
  10. Avoid right-handed indexes based on a growing sequence.
  11. Be aware of the degree of selectivity of indexes. Use B*tree indexes for large cardinality columns and bitmap indexes for low cardinality columns.
  12. Avoid sort, distinct, union when possible [the 24GB TEMP TS gets full up to the top - how do they manage to do that?]; "union all" does not need sorting.
  13. Avoid IN lists with more than aprox. 10 entries.
    [but how to rewrite the code?]
  14. Avoid NULL values in indexes columns.
  15. Prefer joins instead of subselects.
  16. Avoid outer joins and full outer joins [but how to rewrite the code?].
  17. Avoid PL/SQL loops of single steps if it can all be done in SQL.
    [examples?]
  18. Avoid uncommitted long-running DML operations in order not to overflow the Undo tablespace [best simple solution?]
  19. How to cope with the "Snapshot too old" problem.
  20. Avoid filling rows in two steps: insert and update. Better combine rows together and insert them in one strike [example?]. Even insert into several tables is possible (9i).
  21. Always name your objects (for example: indexes). System given names can cause trouble for the Admin.
  22. Do not specify any storage clauses without a special reason. The Admin should be consulted in this case.
  23. The only tablespace that should be explicitly named is the one for indexes.
  24. Do not grant DML rights to others acting on your schema.
  25. If the use of your scripts is not restricted by yourself or if they are going to be used reliably on a regular base (for example, monthly reports), then write your statements based on views and/or synonyms to avoid a direct dependency on the underlying schema. If the schema (removing column etc.) is changed, a redefinition of the view will be enough not to break all dependent scripts.
  26. If a GUI is planned for a set of scripts, put all your scripts in the DB as stored procedures; they will be available no matter which GUI is going to be used.

For more advanced users:
27) Learn how to use the autotrace mode of sqlplus.

28) Learn how to use the explain plan command and interpret results.

29) Using hints to improve performance

Still missing:

  1. Guidelines for use of temporary tables, examples (improving performance).
  2. How to force execution on the remote host side when using a database link (if appropriate).
  3. Best GUI or RAD or IDE ("grafical user interface", "rapid application development", "integrated development environment") for Oracle [some use Access as a Front-End and get into problems]; either an Oracle product or third party one (?); recommendations on advantages/disadvantages.

My problem with this is that users expect from me very specific information about how to make their queries run faster. The performance resources known to me reside on the Admin's responsibility and are mostly already enforced. What I need now is a compilation of understandable guidelines for sql writers. I can't find anything related in the Web. If you take a look at http://www.dbdomain.com/article8.htm
you will realize that all this stuff is for the Admin in the first place, and not appropriate for casual DB users.

Your input will be high appreciated!

Regards
Rick Denoire Received on Sat Feb 14 2004 - 08:20:56 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US