@@ -296,13 +296,13 @@ ____________________________________________________________________________-->
296
296
just after making major changes in the contents of a table. Accurate
297
297
statistics will help the planner to choose the most appropriate query
298
298
plan, and thereby improve the speed of query processing. A common
299
- strategy for read-mostly databases is to run <xref linkend="sql-vacuum"/ >
299
+ strategy for read-mostly databases is to run <link linkend="sql-vacuum"><command>VACUUM</command></link >
300
300
and <command>ANALYZE</command> once a day during a low-usage time of day.
301
301
(This will not be sufficient if there is heavy update activity.)
302
302
</para>
303
303
____________________________________________________________________________-->
304
304
<para>
305
- 在默认的<productname>PostgreSQL</productname>配置中,自动清理守护进程(见<xref linkend="autovacuum"/>)会在表第一次载入数据或者用常规操作改变时负责表的自动分析。当启用自动清理时,定期运行<command>ANALYZE</command>是个好主意,或者可以在表内容做了大的修改后运行<command>ANALYZE</command>。准确的统计信息将帮助规划器选择最合适的查询计划,从而提升查询处理的速度。主读数据库的一般策略是在一天中使用量最低时运行一次<xref linkend="sql-vacuum"/ >和<command>ANALYZE</command>(如果有大量的更新动作则是不够的)。
305
+ 在默认的<productname>PostgreSQL</productname>配置中,自动清理守护进程(见<xref linkend="autovacuum"/>)会在表第一次载入数据或者用常规操作改变时负责表的自动分析。当启用自动清理时,定期运行<command>ANALYZE</command>是个好主意,或者可以在表内容做了大的修改后运行<command>ANALYZE</command>。准确的统计信息将帮助规划器选择最合适的查询计划,从而提升查询处理的速度。主读数据库的一般策略是在一天中使用量最低时运行一次<link linkend="sql-vacuum"><command>VACUUM</command></link >和<command>ANALYZE</command>(如果有大量的更新动作则是不够的)。
306
306
</para>
307
307
308
308
<!--==========================orignal english content==========================
@@ -342,24 +342,24 @@ ____________________________________________________________________________-->
342
342
will change slightly each time <command>ANALYZE</command> is run,
343
343
even if the actual table contents did not change. This might result
344
344
in small changes in the planner's estimated costs shown by
345
- <xref linkend="sql-explain"/ >.
345
+ <link linkend="sql-explain"><command>EXPLAIN</command></link >.
346
346
In rare situations, this non-determinism will cause the planner's
347
347
choices of query plans to change after <command>ANALYZE</command> is run.
348
348
To avoid this, raise the amount of statistics collected by
349
349
<command>ANALYZE</command>, as described below.
350
350
</para>
351
351
____________________________________________________________________________-->
352
352
<para>
353
- 对于大型的表,<command>ANALYZE</command>会对表内容做随机采样而不是检查每一行。这允许在很少的时间内完成对大型表的分析。不过要注意,这些统计信息只是近似值,并且即使实际表内容没有改变,每次运行<command>ANALYZE</command>时统计信息都会有微小地改变。这可能会导致<xref linkend="sql-explain"/ >显示的规划器估算代价有小的改变。在很少的情况下,这会非决定性地导致规划器的查询计划选择在<command>ANALYZE</command>运行后改变。为了避免这种情况,可以按照下文所述提高<command>ANALYZE</command>所收集的统计信息量。
353
+ 对于大型的表,<command>ANALYZE</command>会对表内容做随机采样而不是检查每一行。这允许在很少的时间内完成对大型表的分析。不过要注意,这些统计信息只是近似值,并且即使实际表内容没有改变,每次运行<command>ANALYZE</command>时统计信息都会有微小地改变。这可能会导致<link linkend="sql-explain"><command>EXPLAIN</command></link >显示的规划器估算代价有小的改变。在很少的情况下,这会非决定性地导致规划器的查询计划选择在<command>ANALYZE</command>运行后改变。为了避免这种情况,可以按照下文所述提高<command>ANALYZE</command>所收集的统计信息量。
354
354
</para>
355
355
356
356
<!--==========================orignal english content==========================
357
357
<para>
358
358
The extent of analysis can be controlled by adjusting the
359
359
<xref linkend="guc-default-statistics-target"/> configuration variable, or
360
360
on a column-by-column basis by setting the per-column statistics
361
- target with <command>ALTER TABLE ... ALTER COLUMN ... SET
362
- STATISTICS</command> (see <xref linkend="sql-altertable"/>) .
361
+ target with <link linkend="sql-altertable">< command>ALTER TABLE ... ALTER COLUMN ... SET
362
+ STATISTICS</command></link> .
363
363
The target value sets the
364
364
maximum number of entries in the most-common-value list and the
365
365
maximum number of bins in the histogram. The default target value
@@ -375,7 +375,7 @@ ____________________________________________________________________________-->
375
375
</para>
376
376
____________________________________________________________________________-->
377
377
<para>
378
- 通过调整<xref linkend="guc-default-statistics-target"/>配置变量可以控制分析量,对每个列可以用<command>ALTER TABLE ... ALTER COLUMN ... SET STATISTICS</command>设置每列的统计信息目标(见<xref linkend="sql-altertable"/>) 。目标值会设置最常用值列表中的最大项数以及直方图中的最大容器数。默认目标值是 100,可以把它调大或者调小在规划器估计值精度和<command>ANALYZE</command>花费的时间以及<literal>pg_statistic</literal>所占空间之间做出平衡。特别地,将统计信息目标设置为零会禁用该列的统计信息收集。在查询的<literal>WHERE</literal>、<literal>GROUP BY</literal>或者<literal>ORDER BY</literal>子句中从不出现的列上这样做会有所帮助,因为规划器用不上这些列上的统计信息。
378
+ 通过调整<xref linkend="guc-default-statistics-target"/>配置变量可以控制分析量,对每个列可以用<link linkend="sql-altertable">< command>ALTER TABLE ... ALTER COLUMN ... SET STATISTICS</command></link>设置每列的统计信息目标 。目标值会设置最常用值列表中的最大项数以及直方图中的最大容器数。默认目标值是 100,可以把它调大或者调小在规划器估计值精度和<command>ANALYZE</command>花费的时间以及<literal>pg_statistic</literal>所占空间之间做出平衡。特别地,将统计信息目标设置为零会禁用该列的统计信息收集。在查询的<literal>WHERE</literal>、<literal>GROUP BY</literal>或者<literal>ORDER BY</literal>子句中从不出现的列上这样做会有所帮助,因为规划器用不上这些列上的统计信息。
379
379
</para>
380
380
381
381
<!--==========================orignal english content==========================
@@ -398,12 +398,11 @@ ____________________________________________________________________________-->
398
398
with the largest possible statistics target. If this inaccuracy leads to
399
399
bad query plans, a more accurate value can be determined manually and then
400
400
installed with
401
- <command>ALTER TABLE ... ALTER COLUMN ... SET (n_distinct = ...)</command>
402
- (see <xref linkend="sql-altertable"/>).
401
+ <link linkend="sql-altertable"><command>ALTER TABLE ... ALTER COLUMN ... SET (n_distinct = ...)</command></link>.
403
402
</para>
404
403
____________________________________________________________________________-->
405
404
<para>
406
- <command>ANALYZE</command>所估算的值之一是出现在每个列中的可区分值。因为只会检查行的一个子集,即便使用最大的统计信息目标,这种估计有时也可能很不精确。如果这种不精确导致不好的查询计划,可以手工确定一个更精确的值并且用<command>ALTER TABLE ... ALTER COLUMN ... SET (n_distinct = ...)</command>设置该值(见<xref linkend="sql-altertable"/>) 。
405
+ <command>ANALYZE</command>所估算的值之一是出现在每个列中的可区分值。因为只会检查行的一个子集,即便使用最大的统计信息目标,这种估计有时也可能很不精确。如果这种不精确导致不好的查询计划,可以手工确定一个更精确的值并且用<link linkend="sql-altertable">< command>ALTER TABLE ... ALTER COLUMN ... SET (n_distinct = ...)</command></link>设置该值 。
407
406
</para>
408
407
409
408
<!--==========================orignal english content==========================
@@ -445,6 +444,18 @@ ____________________________________________________________________________-->
445
444
<para>
446
445
如果被分析的表不完全为空,<command>ANALYZE</command>将不会为该表记录新统计信息。任何现有统计信息将会被保留。
447
446
</para>
447
+
448
+ <!--==========================orignal english content==========================
449
+ <para>
450
+ Each backend running <command>ANALYZE</command> will report its progress
451
+ in the <structname>pg_stat_progress_analyze</structname> view. See
452
+ <xref linkend="analyze-progress-reporting"/> for details.
453
+ </para>
454
+ ____________________________________________________________________________-->
455
+ <para>
456
+ 每个运行<command>ANALYZE</command>的后端将会在<structname>pg_stat_progress_analyze</structname>
457
+ 视图中报告其进度。详细参考<xref linkend="analyze-progress-reporting"/>。
458
+ </para>
448
459
</refsect1>
449
460
450
461
<refsect1>
@@ -474,6 +485,7 @@ ____________________________________________________________________________-->
474
485
<member><xref linkend="app-vacuumdb"/></member>
475
486
<member><xref linkend="runtime-config-resource-vacuum-cost"/></member>
476
487
<member><xref linkend="autovacuum"/></member>
488
+ <member><xref linkend="analyze-progress-reporting"/></member>
477
489
</simplelist>
478
490
</refsect1>
479
491
</refentry>
0 commit comments