Entering content frame

Background documentation Database Design Tips Locate the document in the library structure

The database design has a large influence on performance when the system is in operation. In particular, note the following factors:

·        Search Conditions

·        Type of SQL statement (SELECT, INSERT, UPDATE, DELETE)

·        Elements of SELECT statements (ORDER clause, UPDATE clause, DISTINCT specification, FOR REUSE designation)

·        Type of physical storage of tables

·        Size of tables (number of rows and B* tree pages, see Data Storage and Access)

Many performance problems can be avoided if you observe the following tips when designing your database:

·        Before you define tables, analyze the expected data.

When defining key columns, place those columns that are especially selective and for which users frequently enter search conditions at the beginning of the key. In many cases, the database system will then only have to search a small part of the table when processing a SELECT statement.

·        Only invert columns with high selectivity.

Do not choose columns such as gender or marital status as indexes. As a rule, such columns have very few different values and the database system can only seldom use them for non-sequential searches.

·        In the case of relatively static datasets, you can invert a large number of tables. When defining the key columns at the beginning of the index, use selective columns that users frequently use in equality conditions.

·        Do not invert all columns which users use in search conditions. The space needed for the indexes and the cost of maintaining them is considerable.

·        If many changes have been made in a table, update the SQL Optimizer Statistics.

·        Do not formulate search conditions that are fulfilled by all rows.

When users can freely choose the values of a search condition, they frequently do not enter any value. The database system must then evaluate the ineffectual search condition for every row included in the search. It is better to execute different SELECT statements depending on the user input.

·        Place the most selective search conditions at the beginning of the search condition. That way the database system may be able to complete the search before it has evaluated all the search conditions.

·        The search condition

columnx IN (1,13,24,...)

can be evaluated more efficiently by the Optimizer than the semantically-identical search condition

columnx=1 OR columnx=13 OR columnx=24 OR ...

See also:

Performance

 

Leaving content frame