powered by simpleCommunicator - 2.0.61     © 2026 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / Oracle [игнор отключен] [закрыт для гостей] / Замещающий (INSTEAD) триггер тормозит на внутреннем системном запросе Oracle
5 сообщений из 5, страница 1 из 1
Замещающий (INSTEAD) триггер тормозит на внутреннем системном запросе Oracle
    #39617490
azav
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Здравствуйте, разумные.

Передали на сопровождение чужой подтормаживающий код.
Вставка записей идет во вьюху, на которую повешен замещающий (INSTEAD) триггер, который и делает нужные INSERT/UPDATE/DELETE в 3 таблицы.
Сделал трейс тормозящего куска сессии.
При анализе вижу, что 90% времени по сессии теряется на запрос, который вызывается при каждой вставке:

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

Код: plsql
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
SELECT C1, C2, C3
  FROM (SELECT ACC.COLUMN_NAME     C1,
               ACC.CONSTRAINT_NAME C2,
               AC.CONSTRAINT_TYPE  C3
          FROM ALL_CONS_COLUMNS ACC, ALL_CONSTRAINTS AC
         WHERE (AC.CONSTRAINT_TYPE = 'P' OR AC.CONSTRAINT_TYPE = 'U')
           AND AC.TABLE_NAME = :B2
           AND AC.OWNER = :B1
           AND AC.TABLE_NAME = ACC.TABLE_NAME
           AND AC.OWNER = ACC.OWNER
           AND AC.CONSTRAINT_NAME = ACC.CONSTRAINT_NAME
        UNION
        SELECT AIC.COLUMN_NAME C1, AI.INDEX_NAME C2, 'U' C3
          FROM ALL_INDEXES AI, ALL_IND_COLUMNS AIC
         WHERE AI.UNIQUENESS = 'UNIQUE'
           AND AI.TABLE_NAME = :B2
           AND AI.TABLE_OWNER = :B1
           AND AI.TABLE_NAME = AIC.TABLE_NAME
           AND AI.TABLE_OWNER = AIC.TABLE_OWNER
           AND AI.INDEX_NAME = AIC.INDEX_NAME
           AND AI.OWNER = AIC.INDEX_OWNER)
 ORDER BY 3, 2, 1



Запрос порождает внутренний механизм Oracle.
В переданных исходниках ничего подобного нет.
Прошу проконсультировать: откуда берется, как избавиться или оптимизировать.
...
Рейтинг: 0 / 0
Замещающий (INSTEAD) триггер тормозит на внутреннем системном запросе Oracle
    #39617551
Фотография Elic
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
azavЗапрос порождает внутренний механизм Oracle."внутренний механизм Oracle" породил бы запрос к таблицам, а не представлениям. Ищи ещё.
...
Рейтинг: 0 / 0
Замещающий (INSTEAD) триггер тормозит на внутреннем системном запросе Oracle
    #39617568
Вячеслав Любомудров
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Да че тут искать -- [практически] любая фраза из запроса в гугл сразу отправляет на https://support.oracle.com/knowledge/Oracle Database Products/1386371_1.html (это еще не закрытая страничка)
...
Рейтинг: 0 / 0
Замещающий (INSTEAD) триггер тормозит на внутреннем системном запросе Oracle
    #39617629
azav
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
Спасибо за помощь.

Для ищущих сохраню ответ:

The query is executed by the Oracle Data Provider for .Net to gather the primary key and unique column information of the columns selected in the sql query. The only way to reduce the number of times this sql query is executed by ODP.NET is by using Statement Caching.

When you use statement caching, on the first execution of the sql statement. ODP.NET will issue a query to gather the primary key and unique column information. Once it has been gathered, it will store that information in the statement cache. On the next execution of that sql statement on the same connection, it will use the information from the statement cache to execute the sql.

With ODP.NET versions 11.1.0.6.20 or earlier, the statement cache is enabled by default. The Statement Cache Size=10.

With ODP.NET versions 11.1.0.7.20 or later, Self Tuning is introduced and enabled by default. This feature provides dynamic tuning of the statement cache for applications to achieve optimal performance. This eliminates the need to manually tune the cache for an application.


When using ODP.NET versions 11.1.0.7.20 or later and self tuning is disabled manually, you will need to manually set the Statement Cache Size to enable Statement Caching for your application. This is referred to as "Manually Tuning the Cache".

Statement Caching can be turned on in the connection string by using the setting:

Statement Cache Size = <Number of sql statements you want cached> ie. Statement Cache Size=200;The query is executed by the Oracle Data Provider for .Net to gather the primary key and unique column information of the columns selected in the sql query. The only way to reduce the number of times this sql query is executed by ODP.NET is by using Statement Caching.

When you use statement caching, on the first execution of the sql statement. ODP.NET will issue a query to gather the primary key and unique column information. Once it has been gathered, it will store that information in the statement cache. On the next execution of that sql statement on the same connection, it will use the information from the statement cache to execute the sql.

With ODP.NET versions 11.1.0.6.20 or earlier, the statement cache is enabled by default. The Statement Cache Size=10.

With ODP.NET versions 11.1.0.7.20 or later, Self Tuning is introduced and enabled by default. This feature provides dynamic tuning of the statement cache for applications to achieve optimal performance. This eliminates the need to manually tune the cache for an application.


When using ODP.NET versions 11.1.0.7.20 or later and self tuning is disabled manually, you will need to manually set the Statement Cache Size to enable Statement Caching for your application. This is referred to as "Manually Tuning the Cache".

Statement Caching can be turned on in the connection string by using the setting:

Statement Cache Size = <Number of sql statements you want cached> ie. Statement Cache Size=200;
...
Рейтинг: 0 / 0
Замещающий (INSTEAD) триггер тормозит на внутреннем системном запросе Oracle
    #39618257
feagor
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Гость
azav,

Сталкивался с подобным.
Решалось на прикладном уровне явным указанием первичного ключа в компоненте
...
Рейтинг: 0 / 0
5 сообщений из 5, страница 1 из 1
Форумы / Oracle [игнор отключен] [закрыт для гостей] / Замещающий (INSTEAD) триггер тормозит на внутреннем системном запросе Oracle
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]