Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
6_7_opt.pdf
Скачиваний:
17
Добавлен:
21.03.2016
Размер:
1.97 Mб
Скачать

Oracle не работает планировщик заданий

Добавить комментарий

Проблема: На сервере нужно запустить задание(job), которое будет выполняться через определенный промежуток времени. После создания задания (job’а) в Oracle оно не стартует в указанное время, при этом если выполнить вручную — все прекрасно работает. Инструментарий: Oracle 11

Решение: Для ручного выполнения задания (job’а) в Oracle я использовал стандартный команду:

BEGIN

dbms_scheduler.run_job(job_name=>'<Название>');

END;

/

И все работает как часы. Но стоит это же задание запланировать чтобы оно выполнялось в определенное время — ничего не выполняется.

Для просмотра параметров на сервере воспользуемся запросом:

SELECT*FROMv$parameter

Но нас интересует не вся информация, а параметр JOB_QUEUE_PROCESSES. Для выбора информации отдельно по этому параметру воспользуемся запросом:

SELECT*FROMv$parameterWHEREUPPER(name)='JOB_QUEUE_PROCESSES';

Вописание написано что JOB_QUEUE_PROCESSES — максимальное число процессов, разрешенных для выполнения заданий в фоне.

Внашем случае этот параметр равняется нулю (в результате выборки столбец Value = 0). Изменим значение данного параметра с помощью операции:

ALTERsystemSETjob_queue_processes=10;

PS: Все заработало.

How does AUTO_SAMPLE_SIZE work in Oracle Database 11g?

By Hong Su on Apr 08, 2013

When it comes to gathering statistics, one of the most critical decisions you have to make is, what sample size should be used? A 100% sample will ensure accurate statistics but could take a really long time. Whereas a 1% sample will finish

quickly but could result in poor statistics.

The ESTIMATE_PERCENT parameter in the DBMS_STATS.GATHER_*_STATS procedures controls the sample size used when gathering statistics and its default value is AUTO_SAMPLE_SIZE.

In an earlier blog post, we talked about the new implementation of AUTO_SAMPLE_SIZE in Oracle Database 11g in terms of its improvements in the speed and accuracy of statistics gathering compared to the old AUTO_SAMPLE_SIZE prior to Oracle Database 11g.

In this post, we will offer a closer look at the how the new AUTO_SAMPLE_SIZE algorithm works and how it affects the accuracy of the statistics being gathered.

Before we delve into how the new algorithm works, let us briefly recap how the old algorithm works and its downsides. The old AUTO_SAMPLE_SIZE used the following approach:

Step 1. Oracle starts with a small sampling percentage. If histograms need to be gathered, Oracle might materialize the sample, depending on the sampling percentage.

Step 2. Oracle gathers basic column statistics on the sample. For example, suppose a table T has only one columnC1, then the basic stats gathering query looks like below (this is not the exact syntax we use but a simplified version for illustration purpose):

Query 1 Query Gathering Basic Column Statistics Using AUTO_SAMPLE_SIZE Prior to 11g

The select list items in the query correspond to number of rows in table T, number of non-null values, number of distinct values, total column length, minimal and maximal values of column C1 respectively. “X.0000000000” in the FROM clause is the sampling percentage determined by Oracle.

Step 3: if histograms need to be gathered, Oracle issues a SQL query on the sample for each column that requires a histogram.

Step 4: For each column that requires a histogram, Oracle uses several metrics to determine whether the current sample is sufficient:

Non-null value metric: Whether the sample contains sufficient non-null values of this column;

NDV metric: Whether number of distinct values (NDV) can be properly scaled from the sample.

Step 5: If all metrics in step 4 pass, Oracle concludes that the current sample size is sufficient and the histogram creation for that column is complete. Otherwise, it bumps up the sample size and goes though the above steps again until it finds a satisfactory sample or reaches 100% sampling.

Note that step 3 to step 5 are done per column. For example, if there are 3 columns in the table that require histograms. In the first iteration, we get a sample and materialize it. We issue 3 queries, one per column, on the same materialized sample to gather histograms. Suppose Oracle determines that the sample is sufficient for columns 1 and 2 but insufficient for column 3. Then we bump up the sample size. In the second iteration, only 1 query is issued on the sample to gather histogram for column 3.

As you can see the old AUTO_SAMPLE_SIZE can be inefficient if several iterations are required. A dominating