Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Log SQL queries performed by hibernate or nhibernate in the runtime logs.
    • In order to obtain the statements needed for the execution plan, the logging configuration has to be changed. Logging settings in Runtime are customizable and can be found here.

    • Change the logging level for "org.hibernate" from INFO to TRACE if using java and for NHibernate.SQL from ERROR to TRACE if using .NET.

    • Please be aware that DEBUG level is verbose.
  2. Make sure you are performing a relevant workload on your system or you are you operate on the system during a relevant period of time for the workload.
  3. Analyze the log and extract the relevant SQL statements.
  4. Analyze the execution plan for the relevant SQL statements in order to see if the plan is based on full optimization or not. If you need assistance interpreting the execution plan, please contact your Database Administrator.
  5. Monitor the index usage for the indexes that seem to be missing from the relevant statement execution plan and see if they are really needed.
  6. Consider adding bitmap indexes for index keys that frequently used.

  7. Check the additional notes section.

...

  • Open query window
  • Select Include actual execution plan (Ctrl + M) option
  • Write the following statement and execute it
  • Following tab should be available
  • For more details please hover the nodes:

Bitmap indexes

Bitmap indexes are oracle specific indexes that can be used on the columns that have low cardinality, meaning that the column has relatively few unique values. For example in the CASES table, the column STATUS can have only few values. Lets consider OPEN, LOCKED and CLOSED for this example.

In order to create a bitmap index in CASES table on the column STATUS the following query can be executed:

Panel
borderStylenone
CREATE BITMAP INDEX index_name ON CASES (STATUS);

Please consider a bitmap index for any index that with less than 100 distinct values. Also, if your table has one million rows, a column with 10,000 distinct values is a candidate for a bitmap index.You can check how to see an index usage in the section below.

The following columns can represent good candidates considering the above condition:

  • In the case table
    • status
    • locked by
  • In the tasks table
    • status
    • type
  • In attfibutes value table
    • value type
    • boolean value
    • entity value
  • In the custom fields table
    • custom fields name
  • in the aggregate table
    • type
    • latest

SQL Server does not support bitmap indexes, but it has something called bitmap filtering. Contact your Database Administrator for more information about this topic.

...

Monitor the index usage
Anchor
monitoring
monitoring

Indexing can both help and hurt performance. Maintaining indexes can slow things down and also require additional store. These are the main reasons why the indexes that are not used should be removed.

...

  1. Start monitoring the index usage

    Panel
    borderStylenone
    ALTER INDEX index MONITORING USAGE
  2. Workload on the system. Please make sure that the workload is representative for the normal usage of the system.
  3. Stop monitoring the index usage

    Panel
    borderStylenone
    ALTER INDEX index NOMONITORING USAGE
  4. Query for the the index in  in the V$OBJECT_USAGE to see if the index has been used.

    Panel
    borderStylenone

    SELECT USED FORM V$OBJECT_USAGE WHERE INDEX_NAME = 'index'

    The query result will be either yes or no.

...

  1. Workload on the system. Please make sure that the workload is representative for the normal usage of the system.
  2. Run the following query that will expose how many times the index was used for user queries:

    SELECT OBJECT_NAME(S.[OBJECT_ID]) AS [OBJECT NAME], 
           I.[NAME] AS [INDEX NAME], 
           USER_SEEKS, 
           USER_SCANS, 
           USER_LOOKUPS, 
           USER_UPDATES 
    FROM   SYS.DM_DB_INDEX_USAGE_STATS AS S 
           INNER JOIN SYS.INDEXES AS I ON I.[OBJECT_ID] = S.[OBJECT_ID] AND I.INDEX_ID = S.INDEX_ID 
    WHERE  OBJECTPROPERTY(S.[OBJECT_ID],'IsUserTable') = 1
           AND S.database_id = DB_ID(),

     

  3. In order to find indexes that are not used, you need to check the values that have no seeks, scans or lookups but they have updates. 

Bitmap indexes
Anchor
bitmap
bitmap

Bitmap indexes are oracle specific indexes that can be used on the columns that have low cardinality, meaning that the column has relatively few unique values. For example in the CASES table, the column STATUS can have only few values. Lets consider OPEN, LOCKED and CLOSED for this example.

In order to create a bitmap index in CASES table on the column STATUS the following query can be executed:

Panel
borderStylenone
CREATE BITMAP INDEX index_name ON CASES (STATUS);

Please consider a bitmap index for any index that with less than 100 distinct values. Also, if your table has one million rows, a column with 10,000 distinct values is a candidate for a bitmap index.You can check how to see an index usage in the section below.

The following columns can represent good candidates considering the above condition:

  • In the case table
    • status
    • locked by
  • In the tasks table
    • status
    • type
  • In attfibutes value table
    • value type
    • boolean value
    • entity value
  • In the custom fields table
    • custom fields name
  • in the aggregate table
    • type
    • latest

SQL Server does not support bitmap indexes, but it has something called bitmap filtering. Contact your Database Administrator for more information about this topic.