Skip to content

Commit 25f32d8

Browse files
author
gpobs
committed
Update ref/create_statistics.sgml-200531
——row151,调整英文内容为: <literal>ndistinct</literal>, which enables n-distinct statistics, ——row153至154,调整英文内容为: dependency statistics, and <literal>mcv</literal> which enables most-common values lists. ——row163,调整中文内容为: <literal>ndistinct</literal>,启用功能依赖性统计的<literal>dependencies</literal>,以及启用最常见的值列表的<literal>mcv</literal>。 ——row180至181,调整英文内容为: At least two column names must be given; the order of the column names is insignificant. ——row185,调整中文内容 被计算的统计信息包含的表格列的名称。至少必须给出两个列名,列名的顺序可以忽略。 ——row305至360,增加英文和中文内容为: <!--==========================orignal english content========================== <para> Create table <structname>t2</structname> with two perfectly correlated columns (containing identical data), and a MCV list on those columns: <programlisting> CREATE TABLE t2 ( a int, b int ); INSERT INTO t2 SELECT mod(i,100), mod(i,100) FROM generate_series(1,1000000) s(i); CREATE STATISTICS s2 (mcv) ON a, b FROM t2; ANALYZE t2; -- valid combination (found in MCV) EXPLAIN ANALYZE SELECT * FROM t2 WHERE (a = 1) AND (b = 1); -- invalid combination (not found in MCV) EXPLAIN ANALYZE SELECT * FROM t2 WHERE (a = 1) AND (b = 2); </programlisting> The MCV list gives the planner more detailed information about the specific values that commonly appear in the table, as well as an upper bound on the selectivities of combinations of values that do not appear in the table, allowing it to generate better estimates in both cases. </para> ____________________________________________________________________________--> <para> 创建表<structname>t2</structname>与两个完全相关的列(包含相同的数据),并且在这些列上创建一个MCV列表: <programlisting> CREATE TABLE t2 ( a int, b int ); INSERT INTO t2 SELECT mod(i,100), mod(i,100) FROM generate_series(1,1000000) s(i); CREATE STATISTICS s2 (mcv) ON a, b FROM t2; ANALYZE t2; -- valid combination (found in MCV) EXPLAIN ANALYZE SELECT * FROM t2 WHERE (a = 1) AND (b = 1); -- invalid combination (not found in MCV) EXPLAIN ANALYZE SELECT * FROM t2 WHERE (a = 1) AND (b = 2); </programlisting> MCV列表为计划器提供了关于表中普遍出现的特定值的更详细的信息,以及表中未显示的值组合的选择性上限,允许它在这两种情况下产生更好的估计值。 </para>
1 parent 4e06837 commit 25f32d8

File tree

1 file changed

+67
-8
lines changed

1 file changed

+67
-8
lines changed

postgresql/doc/src/sgml/ref/create_statistics.sgml

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,10 @@ ____________________________________________________________________________-->
148148
<para>
149149
A statistics kind to be computed in this statistics object.
150150
Currently supported kinds are
151-
<literal>ndistinct</literal>, which enables n-distinct statistics, and
151+
<literal>ndistinct</literal>, which enables n-distinct statistics,
152152
<literal>dependencies</literal>, which enables functional
153-
dependency statistics.
153+
dependency statistics, and <literal>mcv</literal> which enables
154+
most-common values lists.
154155
If this clause is omitted, all supported statistics kinds are
155156
included in the statistics object.
156157
For more information, see <xref linkend="planner-stats-extended"/>
@@ -159,10 +160,10 @@ ____________________________________________________________________________-->
159160
____________________________________________________________________________-->
160161
<para>
161162
在此统计对象中计算的统计种类。目前支持的种类是启用n-distinct统计的
162-
<literal>ndistinct</literal>,以及启用功能依赖性统计的<literal>dependencies</literal>。
163-
如果省略该子句,则统计对象中将包含所有支持的统计类型。
164-
有关更多信息,请参阅<xref linkend="planner-stats-extended"/>和
165-
<xref linkend="multivariate-statistics-examples"/>。
163+
<literal>ndistinct</literal>,启用功能依赖性统计的<literal>dependencies</literal>,以及启用最常见的值列表的<literal>mcv</literal>。
164+
如果省略该子句,则统计对象中将包含所有支持的统计类型。
165+
有关更多信息,请参阅<xref linkend="planner-stats-extended"/>和
166+
<xref linkend="multivariate-statistics-examples"/>。
166167
</para>
167168
</listitem>
168169
</varlistentry>
@@ -176,11 +177,12 @@ ____________________________________________________________________________-->
176177
<!--==========================orignal english content==========================
177178
<para>
178179
The name of a table column to be covered by the computed statistics.
179-
At least two column names must be given.
180+
At least two column names must be given; the order of the column names
181+
is insignificant.
180182
</para>
181183
____________________________________________________________________________-->
182184
<para>
183-
被计算的统计信息包含的表格列的名称。至少必须给出两个列名。
185+
被计算的统计信息包含的表格列的名称。至少必须给出两个列名,列名的顺序可以忽略
184186
</para>
185187
</listitem>
186188
</varlistentry>
@@ -300,6 +302,63 @@ EXPLAIN ANALYZE SELECT * FROM t1 WHERE (a = 1) AND (b = 0);
300302
通过这样的统计,规划器认识到<literal>WHERE</literal>条件是多余的,并且不会低估行数。
301303
</para>
302304

305+
<!--==========================orignal english content==========================
306+
<para>
307+
Create table <structname>t2</structname> with two perfectly correlated columns
308+
(containing identical data), and a MCV list on those columns:
309+
310+
<programlisting>
311+
CREATE TABLE t2 (
312+
a int,
313+
b int
314+
);
315+
316+
INSERT INTO t2 SELECT mod(i,100), mod(i,100)
317+
FROM generate_series(1,1000000) s(i);
318+
319+
CREATE STATISTICS s2 (mcv) ON a, b FROM t2;
320+
321+
ANALYZE t2;
322+
323+
-&minus; valid combination (found in MCV)
324+
EXPLAIN ANALYZE SELECT * FROM t2 WHERE (a = 1) AND (b = 1);
325+
326+
-&minus; invalid combination (not found in MCV)
327+
EXPLAIN ANALYZE SELECT * FROM t2 WHERE (a = 1) AND (b = 2);
328+
</programlisting>
329+
330+
The MCV list gives the planner more detailed information about the
331+
specific values that commonly appear in the table, as well as an upper
332+
bound on the selectivities of combinations of values that do not appear
333+
in the table, allowing it to generate better estimates in both cases.
334+
</para>
335+
____________________________________________________________________________-->
336+
<para>
337+
创建表<structname>t2</structname>与两个完全相关的列(包含相同的数据),并且在这些列上创建一个MCV列表:
338+
339+
<programlisting>
340+
CREATE TABLE t2 (
341+
a int,
342+
b int
343+
);
344+
345+
INSERT INTO t2 SELECT mod(i,100), mod(i,100)
346+
FROM generate_series(1,1000000) s(i);
347+
348+
CREATE STATISTICS s2 (mcv) ON a, b FROM t2;
349+
350+
ANALYZE t2;
351+
352+
-- valid combination (found in MCV)
353+
EXPLAIN ANALYZE SELECT * FROM t2 WHERE (a = 1) AND (b = 1);
354+
355+
-- invalid combination (not found in MCV)
356+
EXPLAIN ANALYZE SELECT * FROM t2 WHERE (a = 1) AND (b = 2);
357+
</programlisting>
358+
359+
MCV列表为计划器提供了关于表中普遍出现的特定值的更详细的信息,以及表中未显示的值组合的选择性上限,允许它在这两种情况下产生更好的估计值。
360+
</para>
361+
303362
</refsect1>
304363

305364
<refsect1>

0 commit comments

Comments
 (0)