bk commit - mysqldoc@docsrva tree (paul:1.3282)  
Author Message
paul





PostPosted: 2005-8-16 3:12:52 Top

mysql, bk commit - mysqldoc@docsrva tree (paul:1.3282) Below is the list of changes that have just been committed into a local
mysqldoc repository of paul. When paul does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet
1.3282 05/08/15 14:12:17 email***@***.com +4 -0
De-cruft.

refman/mysql-optimization.xml
1.10 05/08/15 14:12:17 email***@***.com +40 -58
De-cruft.

refman-5.1/mysql-optimization.xml
1.6 05/08/15 14:12:17 email***@***.com +96 -107
De-cruft.

refman-5.0/mysql-optimization.xml
1.6 05/08/15 14:12:16 email***@***.com +96 -107
De-cruft.

refman-4.1/mysql-optimization.xml
1.11 05/08/15 14:12:16 email***@***.com +206 -199
De-cruft.

refman/mysql-optimization.xml
1.9 05/08/15 14:00:44 email***@***.com +8 -12

refman-5.1/mysql-optimization.xml
1.5 05/08/15 14:00:44 email***@***.com +8 -12

refman-5.0/mysql-optimization.xml
1.5 05/08/15 14:00:44 email***@***.com +8 -12

refman-4.1/mysql-optimization.xml
1.10 05/08/15 14:00:43 email***@***.com +8 -12

# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: paul
# Host: kite-hub.kitebird.com
# Root: /src/extern/MySQL/bk/mysqldoc

--- 1.4/refman-5.1/mysql-optimization.xml 2005-08-10 05:44:19 -05:00
+++ 1.6/refman-5.1/mysql-optimization.xml 2005-08-15 14:12:17 -05:00
@@ -925,16 +925,16 @@

<itemizedlist>

- <indexterm type="concept">
- <primary>system table</primary>
- </indexterm>
+ <listitem>
+ <indexterm type="concept">
+ <primary>system table</primary>
+ </indexterm>

- <indexterm type="concept">
- <primary>tables</primary>
- <secondary>system</secondary>
- </indexterm>
+ <indexterm type="concept">
+ <primary>tables</primary>
+ <secondary>system</secondary>
+ </indexterm>

- <listitem>
<para>
<literal>system</literal>
</para>
@@ -943,20 +943,18 @@
The table has only one row (= system table). This is a
special case of the <literal>const</literal> join type.
</para>
-
- <para>
- <indexterm type="concept">
- <primary>constant table</primary>
- </indexterm>
-
- <indexterm type="concept">
- <primary>tables</primary>
- <secondary>constant</secondary>
- </indexterm>
- </para>
</listitem>

<listitem>
+ <indexterm type="concept">
+ <primary>constant table</primary>
+ </indexterm>
+
+ <indexterm type="concept">
+ <primary>tables</primary>
+ <secondary>constant</secondary>
+ </indexterm>
+
<para>
<literal>const</literal>
</para>
@@ -979,14 +977,12 @@
<literal>const</literal> table:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>tbl_name</replaceable> WHERE <replaceable>primary_key</replaceable>=1;

SELECT * FROM <replaceable>tbl_name</replaceable>
WHERE <replaceable>primary_key_part1</replaceable>=1 AND <replaceable>primary_key_part2</replaceable>=2;
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1018,7 +1014,6 @@
<replaceable>ref_table</replaceable>:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>ref_table</replaceable>,<replaceable>other_table</replaceable>
WHERE <replaceable>ref_table</replaceable>.<replaceable>key_column</replaceable>=<replaceable>other_table</replaceable>.<replaceable>column</replaceable>;
@@ -1027,7 +1022,6 @@
WHERE <replaceable>ref_table</replaceable>.<replaceable>key_column_part1</replaceable>=<replaceable>other_table</replaceable>.<replaceable>column</replaceable>
AND <replaceable>ref_table</replaceable>.<replaceable>key_column_part2</replaceable>=1;
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1061,7 +1055,6 @@
<replaceable>ref_table</replaceable>:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>ref_table</replaceable> WHERE <replaceable>key_column</replaceable>=<replaceable>expr</replaceable>;

@@ -1072,7 +1065,6 @@
WHERE <replaceable>ref_table</replaceable>.<replaceable>key_column_part1</replaceable>=<replaceable>other_table</replaceable>.<replaceable>column</replaceable>
AND <replaceable>ref_table</replaceable>.<replaceable>key_column_part2</replaceable>=1;
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1094,12 +1086,10 @@
<replaceable>ref_table</replaceable>:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>ref_table</replaceable>
WHERE <replaceable>key_column</replaceable>=<replaceable>expr</replaceable> OR <replaceable>key_column</replaceable> IS NULL;
</programlisting>
- </para>

<para>
See <xref linkend="is-null-optimization"/>.
@@ -1130,11 +1120,13 @@
<para>
This type replaces <literal>ref</literal> for some
<literal>IN</literal> subqueries of the following form:
+ </para>

<programlisting>
<replaceable>value</replaceable> IN (SELECT <replaceable>primary_key</replaceable> FROM <replaceable>single_table</replaceable> WHERE <replaceable>some_expr</replaceable>)
</programlisting>

+ <para>
<literal>unique_subquery</literal> is just an index
lookup function that replaces the subquery completely
for better efficiency.
@@ -1153,11 +1145,9 @@
non-unique indexes in subqueries of the following form:
</para>

- <para>
<programlisting>
<replaceable>value</replaceable> IN (SELECT <replaceable>key_column</replaceable> FROM <replaceable>single_table</replaceable> WHERE <replaceable>some_expr</replaceable>)
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1186,7 +1176,6 @@
operators:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>tbl_name</replaceable>
WHERE <replaceable>key_column</replaceable> = 10;
@@ -1200,7 +1189,6 @@
SELECT * FROM <replaceable>tbl_name</replaceable>
WHERE <replaceable>key_part1</replaceable>= 10 AND <replaceable>key_part2</replaceable> IN (10,20,30);
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1328,7 +1316,7 @@
</listitem>

<!--
- TODO: We don't seem to explain what ref values of "const", NULL,
+ TODO: We do not seem to explain what ref values of "const", NULL,
or <replaceable>tbl_name.col_name</replaceable> mean.
-->

@@ -1385,12 +1373,10 @@
optimized this way:
</para>

- <para>
<programlisting>
SELECT * FROM t1 LEFT JOIN t2 ON t1.id=t2.id
WHERE t2.id IS NULL;
</programlisting>
- </para>

<para>
Assume that <literal>t2.id</literal> is defined as
@@ -2004,35 +1990,35 @@
<listitem>
<para>
Removal of unnecessary parentheses:
+ </para>

<programlisting>
((a AND b) AND c OR (((a AND b) AND (c AND d))))
-> (a AND b AND c) OR (a AND b AND c AND d)
</programlisting>
- </para>
</listitem>

<listitem>
<para>
Constant folding:
+ </para>

<programlisting>
(a<b AND b=c) AND a=5
-> b>5 AND b=c AND a=5
</programlisting>
- </para>
</listitem>

<listitem>
<para>
Constant condition removal (needed because of constant
folding):
+ </para>

<programlisting>
(B>=5 AND B=5) OR (B=6 AND 5=5) OR (B=7 AND 5=6)
-> B=5 OR B=6
</programlisting>
- </para>
</listitem>

<listitem>
@@ -3536,40 +3522,42 @@
the columns required for the query as well. This avoids reading
the rows twice. The <literal>filesort</literal> algorithm works
like this:
+ </para>

- <orderedlist>
+ <orderedlist>

- <listitem>
- <para>
- Read the rows that match the <literal>WHERE</literal>
- clause, as before.
- </para>
- </listitem>
+ <listitem>
+ <para>
+ Read the rows that match the <literal>WHERE</literal>
+ clause, as before.
+ </para>
+ </listitem>

- <listitem>
- <para>
- For each row, record a tuple of values consisting of the
- sort key value and row position, and also the columns
- required for the query.
- </para>
- </listitem>
+ <listitem>
+ <para>
+ For each row, record a tuple of values consisting of the
+ sort key value and row position, and also the columns
+ required for the query.
+ </para>
+ </listitem>

- <listitem>
- <para>
- Sort the tuples by sort key value
- </para>
- </listitem>
+ <listitem>
+ <para>
+ Sort the tuples by sort key value
+ </para>
+ </listitem>

- <listitem>
- <para>
- Retrieve the rows in sorted order, but read the required
- columns directly from the sorted tuples rather than by
- accessing the table a second time.
- </para>
- </listitem>
+ <listitem>
+ <para>
+ Retrieve the rows in sorted order, but read the required
+ columns directly from the sorted tuples rather than by
+ accessing the table a second time.
+ </para>
+ </listitem>

- </orderedlist>
+ </orderedlist>

+ <para>
This algorithm represents an improvement over that used in some
older versions of MySQL.
</para>
@@ -4507,17 +4495,16 @@
important for you, you should consider using the table in
ways that avoid deleting rows. Another possibility is to run
<literal>OPTIMIZE TABLE</literal> after you have deleted a
- lot of rows.
- See <xref linkend="myisam-storage-engine"/>.
+ lot of rows. See <xref linkend="myisam-storage-engine"/>.
</para>
</listitem>

<listitem>
<para>
- To fix any compression issues that may have occurred
- with <literal>ARCHIVE</literal> tables
- you can always do an <literal>OPTIMIZE TABLE</literal>.
- See <xref linkend="archive-storage-engine"/>.
+ To fix any compression issues that may have occurred with
+ <literal>ARCHIVE</literal> tables you can always do an
+ <literal>OPTIMIZE TABLE</literal>. See
+ <xref linkend="archive-storage-engine"/>.
</para>
</listitem>

@@ -5154,42 +5141,42 @@

<para>
Options other than row-level or page-level locking:
+ </para>

- <itemizedlist>
+ <itemizedlist>

- <listitem>
- <para>
- Versioning (such as that used in MySQL for concurrent
- inserts) where it is possible to have one writer at the
- same time as many readers. This means that the database or
- table supports different views for the data depending on
- when access begins. Other common terms for this are
- <quote>time travel</quote>, <quote>copy on write</quote>,
- or <quote>copy on demand</quote>.
- </para>
- </listitem>
+ <listitem>
+ <para>
+ Versioning (such as that used in MySQL for concurrent
+ inserts) where it is possible to have one writer at the same
+ time as many readers. This means that the database or table
+ supports different views for the data depending on when
+ access begins. Other common terms for this are <quote>time
+ travel</quote>, <quote>copy on write</quote>, or <quote>copy
+ on demand</quote>.
+ </para>
+ </listitem>

- <listitem>
- <para>
- Copy on demand is in many cases superior to page-level or
- row-level locking. However, in the worst case, it can use
- much more memory than using normal locks.
- </para>
- </listitem>
+ <listitem>
+ <para>
+ Copy on demand is in many cases superior to page-level or
+ row-level locking. However, in the worst case, it can use
+ much more memory than using normal locks.
+ </para>
+ </listitem>

- <listitem>
- <para>
- Instead of using row-level locks, you can employ
- application-level locks, such as
- <literal>GET_LOCK()</literal> and
- <literal>RELEASE_LOCK()</literal> in MySQL. These are
- advisory locks, so they work only in well-behaved
- applications.
- </para>
- </listitem>
+ <listitem>
+ <para>
+ Instead of using row-level locks, you can employ
+ application-level locks, such as
+ <literal>GET_LOCK()</literal> and
+ <literal>RELEASE_LOCK()</literal> in MySQL. These are
+ advisory locks, so they work only in well-behaved
+ applications.
+ </para>
+ </listitem>

- </itemizedlist>
- </para>
+ </itemizedlist>

</section>

@@ -6133,12 +6120,12 @@
<para>
The following <literal>SELECT</literal> statements do
<emphasis>not</emphasis> use indexes:
+ </para>

<programlisting>
SELECT * FROM <replaceable>tbl_name</replaceable> WHERE <replaceable>key_col</replaceable> LIKE '%Patrick%';
SELECT * FROM <replaceable>tbl_name</replaceable> WHERE <replaceable>key_col</replaceable> LIKE <replaceable>other_col</replaceable>;
</programlisting>
- </para>

<para>
In the first statement, the <literal>LIKE</literal> value begins
@@ -6185,6 +6172,7 @@

<para>
The following <literal>WHERE</literal> clauses use indexes:
+ </para>

<programlisting>
... WHERE <replaceable>index_part1</replaceable>=1 AND <replaceable>index_part2</replaceable>=2 AND <replaceable>other_column</replaceable>=3
@@ -6195,7 +6183,6 @@
/* Can use index on <replaceable>index1</replaceable> but not on <replaceable>index2</replaceable> or <replaceable>index3</replaceable> */
... WHERE <replaceable>index1</replaceable>=1 AND <replaceable>index2</replaceable>=2 OR <replaceable>index1</replaceable>=3 AND <replaceable>index3</replaceable>=3;
</programlisting>
- </para>

<para>
These <literal>WHERE</literal> clauses do
@@ -6523,6 +6510,7 @@
<para>
Note that you cannot destroy the default key cache. An attempt
to do this will be ignored:
+ </para>

<programlisting>
mysql> <userinput>set global key_buffer_size = 0;</userinput>
@@ -6534,7 +6522,6 @@
| key_buffer_size | 8384512 |
+-----------------+---------+
</programlisting>
- </para>

<para>
Key cache variables are structured system variables that have
@@ -8234,16 +8221,14 @@
better, assuming that the disk is not used for other
purposes as well. See <xref linkend="symbolic-links"/>.
</para>
-
- <para>
- <indexterm type="concept">
- <primary>striping</primary>
- <secondary>defined</secondary>
- </indexterm>
- </para>
</listitem>

<listitem>
+ <indexterm type="concept">
+ <primary>striping</primary>
+ <secondary>defined</secondary>
+ </indexterm>
+
<para>
Striping
</para>

--- 1.9/refman-4.1/mysql-optimization.xml 2005-08-12 05:57:41 -05:00
+++ 1.11/refman-4.1/mysql-optimization.xml 2005-08-15 14:12:16 -05:00
@@ -273,7 +273,7 @@
<para>
With MySQL, you can use the <literal>/*! */</literal> syntax to
add MySQL-specific keywords to a query. The code inside
- <literal>/* */</literal> is treated as a comment (and ignored)
+ <literal>/* */</literal> is treated as a comment (and ignored)
by most other SQL servers.
</para>

@@ -917,16 +917,16 @@

<itemizedlist>

- <indexterm type="concept">
- <primary>system table</primary>
- </indexterm>
+ <listitem>
+ <indexterm type="concept">
+ <primary>system table</primary>
+ </indexterm>

- <indexterm type="concept">
- <primary>tables</primary>
- <secondary>system</secondary>
- </indexterm>
+ <indexterm type="concept">
+ <primary>tables</primary>
+ <secondary>system</secondary>
+ </indexterm>

- <listitem>
<para>
<literal>system</literal>
</para>
@@ -935,20 +935,18 @@
The table has only one row (= system table). This is a
special case of the <literal>const</literal> join type.
</para>
-
- <para>
- <indexterm type="concept">
- <primary>constant table</primary>
- </indexterm>
-
- <indexterm type="concept">
- <primary>tables</primary>
- <secondary>constant</secondary>
- </indexterm>
- </para>
</listitem>

<listitem>
+ <indexterm type="concept">
+ <primary>constant table</primary>
+ </indexterm>
+
+ <indexterm type="concept">
+ <primary>tables</primary>
+ <secondary>constant</secondary>
+ </indexterm>
+
<para>
<literal>const</literal>
</para>
@@ -971,14 +969,12 @@
<literal>const</literal> table:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>tbl_name</replaceable> WHERE <replaceable>primary_key</replaceable>=1;

SELECT * FROM <replaceable>tbl_name</replaceable>
WHERE <replaceable>primary_key_part1</replaceable>=1 AND <replaceable>primary_key_part2</replaceable>=2;
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1010,7 +1006,6 @@
<replaceable>ref_table</replaceable>:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>ref_table</replaceable>,<replaceable>other_table</replaceable>
WHERE <replaceable>ref_table</replaceable>.<replaceable>key_column</replaceable>=<replaceable>other_table</replaceable>.<replaceable>column</replaceable>;
@@ -1019,7 +1014,6 @@
WHERE <replaceable>ref_table</replaceable>.<replaceable>key_column_part1</replaceable>=<replaceable>other_table</replaceable>.<replaceable>column</replaceable>
AND <replaceable>ref_table</replaceable>.<replaceable>key_column_part2</replaceable>=1;
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1039,9 +1033,7 @@
a good join type.
</para>

- <para>
<!-- NOTE: The "or <=>" applies only to ref, not to eq_ref. -->
- </para>

<para>
<literal>ref</literal> can be used for indexed columns
@@ -1055,7 +1047,6 @@
<replaceable>ref_table</replaceable>:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>ref_table</replaceable> WHERE <replaceable>key_column</replaceable>=<replaceable>expr</replaceable>;

@@ -1066,7 +1057,6 @@
WHERE <replaceable>ref_table</replaceable>.<replaceable>key_column_part1</replaceable>=<replaceable>other_table</replaceable>.<replaceable>column</replaceable>
AND <replaceable>ref_table</replaceable>.<replaceable>key_column_part2</replaceable>=1;
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1078,8 +1068,8 @@
This join type is like <literal>ref</literal>, but with
the addition that MySQL does an extra search for rows
that contain <literal>NULL</literal> values. This join
- type optimization was added for MySQL 4.1.1 and is
- used mostly when resolving subqueries.
+ type optimization was added for MySQL 4.1.1 and is used
+ mostly when resolving subqueries.
</para>

<para>
@@ -1088,12 +1078,10 @@
<replaceable>ref_table</replaceable>:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>ref_table</replaceable>
WHERE <replaceable>key_column</replaceable>=<replaceable>expr</replaceable> OR <replaceable>key_column</replaceable> IS NULL;
</programlisting>
- </para>

<para>
See <xref linkend="is-null-optimization"/>.
@@ -1108,11 +1096,13 @@
<para>
This type replaces <literal>ref</literal> for some
<literal>IN</literal> subqueries of the following form:
+ </para>

<programlisting>
<replaceable>value</replaceable> IN (SELECT <replaceable>primary_key</replaceable> FROM <replaceable>single_table</replaceable> WHERE <replaceable>some_expr</replaceable>)
</programlisting>

+ <para>
<literal>unique_subquery</literal> is just an index
lookup function that replaces the subquery completely
for better efficiency.
@@ -1131,11 +1121,9 @@
non-unique indexes in subqueries of the following form:
</para>

- <para>
<programlisting>
<replaceable>value</replaceable> IN (SELECT <replaceable>key_column</replaceable> FROM <replaceable>single_table</replaceable> WHERE <replaceable>some_expr</replaceable>)
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1164,7 +1152,6 @@
operators:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>tbl_name</replaceable>
WHERE <replaceable>key_column</replaceable> = 10;
@@ -1178,7 +1165,6 @@
SELECT * FROM <replaceable>tbl_name</replaceable>
WHERE <replaceable>key_part1</replaceable>= 10 AND <replaceable>key_part2</replaceable> IN (10,20,30);
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1304,7 +1290,7 @@
rows from the table.
</para>
</listitem>
-
+
<!--
TODO: We do not seem to explain what ref values of "const", NULL,
or @var{tbl_name.col_name} mean.
@@ -1363,12 +1349,10 @@
optimized this way:
</para>

- <para>
<programlisting>
SELECT * FROM t1 LEFT JOIN t2 ON t1.id=t2.id
WHERE t2.id IS NULL;
</programlisting>
- </para>

<para>
Assume that <literal>t2.id</literal> is defined as
@@ -1401,8 +1385,8 @@
preceding tables, MySQL checks whether it is possible to
use a <literal>range</literal> access method to retrieve
rows. The applicability criteria are as described in
- <xref linkend="range-optimization"/>, with the exception
- that all column values for the preceding table are known
+ <xref linkend="range-optimization"/>, with the exception
+ that all column values for the preceding table are known
and considered to be constants.
</para>

@@ -1953,8 +1937,8 @@

<para>
Note that work on the MySQL optimizer is ongoing, so this
- section is incomplete. MySQL performs a great many
- optimizations, not all of which are documented here.
+ section is incomplete. MySQL performs a great many
+ optimizations, not all of which are documented here.
</para>

<para>
@@ -1966,35 +1950,35 @@
<listitem>
<para>
Removal of unnecessary parentheses:
+ </para>

<programlisting>
((a AND b) AND c OR (((a AND b) AND (c AND d))))
-> (a AND b AND c) OR (a AND b AND c AND d)
</programlisting>
- </para>
</listitem>

<listitem>
<para>
Constant folding:
+ </para>

<programlisting>
(a<b AND b=c) AND a=5
-> b>5 AND b=c AND a=5
</programlisting>
- </para>
</listitem>

<listitem>
<para>
Constant condition removal (needed because of constant
folding):
+ </para>

<programlisting>
(B>=5 AND B=5) OR (B=6 AND 5=5) OR (B=7 AND 5=6)
-> B=5 OR B=6
</programlisting>
- </para>
</listitem>

<listitem>
@@ -2441,8 +2425,8 @@
<para>
The range condition extraction algorithm can handle nested
<literal>AND</literal>/<literal>OR</literal> constructs of
- arbitrary depth, and its output does not depend on the order in
- which conditions appear in <literal>WHERE</literal> clause.
+ arbitrary depth, and its output does not depend on the order
+ in which conditions appear in <literal>WHERE</literal> clause.
</para>

</section>
@@ -2561,7 +2545,7 @@
<literal>BETWEEN</literal>, or <literal>LIKE
'<replaceable>pattern</replaceable>'</literal> (where
<literal>'<replaceable>pattern</replaceable>'</literal>
- does not start with a wildcard). An interval can be used
+ does not start with a wildcard). An interval can be used
as long as it is possible to determine a single key tuple
containing all records that match the condition (or two
intervals if <literal><></literal> or
@@ -2836,9 +2820,9 @@
</para>

<para>
- If you do not use columns from all tables named in a query, MySQL
- stops scanning the not-used tables as soon as it finds the first
- match. In the following case, assuming that
+ If you do not use columns from all tables named in a query,
+ MySQL stops scanning the not-used tables as soon as it finds the
+ first match. In the following case, assuming that
<literal>t1</literal> is used before <literal>t2</literal>
(which you can check with <literal>EXPLAIN</literal>), MySQL
stops reading from <literal>t2</literal> (for any particular row
@@ -2866,7 +2850,7 @@
</indexterm>

<para>
- An <literal>A LEFT JOIN B</literal> join_condition is
+ An <literal>A LEFT JOIN B</literal> join_condition is
implemented in MySQL as follows:
</para>

@@ -2899,9 +2883,9 @@

<listitem>
<para>
- All standard join optimizations are performed, with the
- exception that a table is always read after all tables on
- which it depends. If there is a circular dependence, MySQL
+ All standard join optimizations are performed, with the
+ exception that a table is always read after all tables on
+ which it depends. If there is a circular dependence, MySQL
issues an error.
</para>
</listitem>
@@ -2925,8 +2909,8 @@

<listitem>
<para>
- If you use <literal>LEFT JOIN</literal> to find rows that
- do not exist in some table and you have the following test:
+ If you use <literal>LEFT JOIN</literal> to find rows that do
+ not exist in some table and you have the following test:
<literal><replaceable>col_name</replaceable> IS
NULL</literal> in the <literal>WHERE</literal> part, where
<replaceable>col_name</replaceable> is a column that is
@@ -3019,8 +3003,8 @@

<para>
The index can also be used even if the <literal>ORDER
- BY</literal> does not match the index exactly, as long as all the
- unused index parts and all the extra are <literal>ORDER
+ BY</literal> does not match the index exactly, as long as all
+ the unused index parts and all the extra are <literal>ORDER
BY</literal> columns are constants in the
<literal>WHERE</literal> clause. The following queries use the
index to resolve the <literal>ORDER BY</literal> part:
@@ -3139,8 +3123,8 @@
</indexterm>

<para>
- Prior to MySQL 4.1, in those cases where MySQL must sort the
- result, it uses the following <literal>filesort</literal>
+ Prior to MySQL 4.1, in those cases where MySQL must sort the
+ result, it uses the following <literal>filesort</literal>
algorithm:
</para>

@@ -3948,8 +3932,8 @@

<listitem>
<para>
- If you intend only to read the table in the future, use
- <command>myisampack</command> to make it smaller. See
+ If you intend only to read the table in the future, use
+ <command>myisampack</command> to make it smaller. See
<xref linkend="compressed-format"/>.
</para>
</listitem>
@@ -4000,7 +3984,7 @@
<listitem>
<para>
You can speed up <literal>INSERT</literal> operations that
- are performed with multiple statements by locking your
+ are performed with multiple statements by locking your
tables:
</para>

@@ -4023,8 +4007,8 @@

<para>
For transactional tables, you should use
- <literal>BEGIN</literal> and <literal>COMMIT</literal>
- instead of <literal>LOCK TABLES</literal> to get a speed
+ <literal>BEGIN</literal> and <literal>COMMIT</literal>
+ instead of <literal>LOCK TABLES</literal> to get a speed
increase.
</para>

@@ -4087,17 +4071,17 @@
<title id='title-update-speed'>&title-update-speed;</title>

<para>
- An update statement is optimized like a
- <literal>SELECT</literal> query with the additional overhead of
- a write. The speed of the write depends on the amount of data
- being updated and the number of indexes that are updated.
+ An update statement is optimized like a
+ <literal>SELECT</literal> query with the additional overhead of
+ a write. The speed of the write depends on the amount of data
+ being updated and the number of indexes that are updated.
Indexes that are not changed do not get updated.
</para>

<para>
Also, another way to get fast updates is to delay updates and
- then do many updates in a row later. Performing multiple updates
- together is much quicker than doing one at a time if you lock
+ then do many updates in a row later. Performing multiple updates
+ together is much quicker than doing one at a time if you lock
the table.
</para>

@@ -4116,15 +4100,15 @@
<title id='title-delete-speed'>&title-delete-speed;</title>

<para>
- The time required to delete individual records is exactly
- proportional to the number of indexes. To delete records more
+ The time required to delete individual records is exactly
+ proportional to the number of indexes. To delete records more
quickly, you can increase the size of the key cache. See
<xref linkend="server-parameters"/>.
</para>

<para>
If you want to delete all rows in the table, use
- <literal>TRUNCATE TABLE
+ <literal>TRUNCATE TABLE
<replaceable>tbl_name</replaceable></literal> rather than
<literal>DELETE FROM
<replaceable>tbl_name</replaceable></literal>. See
@@ -4157,9 +4141,9 @@
<listitem>
<para>
Use persistent connections to the database to avoid
- connection overhead. If you cannot use persistent connections
- and you are initiating many new connections to the database,
- you may want to change the value of the
+ connection overhead. If you cannot use persistent
+ connections and you are initiating many new connections to
+ the database, you may want to change the value of the
<literal>thread_cache_size</literal> variable. See
<xref linkend="server-parameters"/>.
</para>
@@ -4197,10 +4181,10 @@

<listitem>
<para>
- To fix any compression issues that may have occurred
- with <literal>ARCHIVE</literal> tables
- you can always do an <literal>OPTIMIZE TABLE</literal>.
- See <xref linkend="archive-storage-engine"/>.
+ To fix any compression issues that may have occurred with
+ <literal>ARCHIVE</literal> tables you can always do an
+ <literal>OPTIMIZE TABLE</literal>. See
+ <xref linkend="archive-storage-engine"/>.
</para>
</listitem>

@@ -4235,7 +4219,7 @@

<listitem>
<para>
- For <literal>MyISAM</literal> tables that change frequently,
+ For <literal>MyISAM</literal> tables that change frequently,
you should try to avoid all variable-length columns
(<literal>VARCHAR</literal>, <literal>BLOB</literal>, and
<literal>TEXT</literal>). The table uses dynamic record
@@ -4247,15 +4231,15 @@
<listitem>
<para>
It is normally not useful to split a table into different
- tables just because the rows become large. In accessing a
- row, the biggest performance hit is the disk seek needed to
- find the first byte of the row. After finding the data, most
- modern disks can read the entire row fast enough for most
- applications. The only cases where splitting up a table
- makes an appreciable difference is if it is a
- <literal>MyISAM</literal> table using dynamic record format
- (see above) that you can change to a fixed record size, or
- if you very often need to scan the table but do not need
+ tables just because the rows become large. In accessing a
+ row, the biggest performance hit is the disk seek needed to
+ find the first byte of the row. After finding the data, most
+ modern disks can read the entire row fast enough for most
+ applications. The only cases where splitting up a table
+ makes an appreciable difference is if it is a
+ <literal>MyISAM</literal> table using dynamic record format
+ (see above) that you can change to a fixed record size, or
+ if you very often need to scan the table but do not need
most of the columns. See <xref linkend="storage-engines"/>.
</para>
</listitem>
@@ -4276,8 +4260,8 @@
This is really important when you use MySQL storage engines
such as <literal>MyISAM</literal> and
<literal>ISAM</literal> that have only table-level locking
- (multiple readers with single writers). This also gives
- better performance with most databases, because the row
+ (multiple readers with single writers). This also gives
+ better performance with most databases, because the row
locking manager in this case has less to do.
</para>
</listitem>
@@ -4315,8 +4299,8 @@

<listitem>
<para>
- In some cases, it is convenient to pack and store data into a
- <literal>BLOB</literal> column. In this case, you must add
+ In some cases, it is convenient to pack and store data into
+ a <literal>BLOB</literal> column. In this case, you must add
some extra code in your application to pack and unpack
information in the <literal>BLOB</literal> values, but this
may save a lot of accesses at some stage. This is practical
@@ -4328,9 +4312,12 @@
<listitem>
<para>
Normally, you should try to keep all data non-redundant
- (known as <firstterm>third normal form</firstterm> in
- database theory). However, do not be afraid to duplicate
- information or create summary tables if necessary to gain
+ (known as
+
+ <firstterm>third normal form</firstterm>
+
+ in database theory). However, do not be afraid to duplicate
+ information or create summary tables if necessary to gain
more speed.
</para>
</listitem>
@@ -4415,8 +4402,8 @@

<listitem>
<para>
- Use <literal>MEMORY</literal> (<literal>HEAP</literal>)
- tables when possible to get more speed. See
+ Use <literal>MEMORY</literal> (<literal>HEAP</literal>)
+ tables when possible to get more speed. See
<xref linkend="memory-storage-engine"/>.
</para>
</listitem>
@@ -4424,10 +4411,10 @@
<listitem>
<para>
When using a normal Web server setup, images should be
- stored as files. That is, only a reference to each file
- should be stored in the database. The main reason for this
- is that a normal Web server is much better at caching files
- than database contents, so it is much easier to get a fast
+ stored as files. That is, only a reference to each file
+ should be stored in the database. The main reason for this
+ is that a normal Web server is much better at caching files
+ than database contents, so it is much easier to get a fast
system if you are using files.
</para>
</listitem>
@@ -4580,8 +4567,8 @@

<para>
In many cases, you can make an educated guess about which
- locking type is best for an application, but generally it is very
- hard to say that a given lock type is better than another.
+ locking type is best for an application, but generally it is
+ very hard to say that a given lock type is better than another.
Everything depends on the application and different parts of an
application may require different lock types.
</para>
@@ -4778,7 +4765,7 @@

<listitem>
<para>
- With higher-level locks, you can also more easily tune
+ With higher-level locks, you can also more easily tune
applications by supporting locks of different types, because
the lock overhead is less than for row-level locks.
</para>
@@ -5119,7 +5106,9 @@
<indexterm type="concept">
<primary>storage of data</primary>
</indexterm>
+
<!-- TODO: This needs review and possible correction. -->
+
<para>
MySQL keeps row data and index data in separate files. Many
(almost all) other databases mix row and index data in the same
@@ -5224,9 +5213,9 @@
</para>

<para>
- MySQL supports many different storage engines (table types) and
- row formats. For each table, you can decide which storage and
- indexing method to use. Choosing the right table format for your
+ MySQL supports many different storage engines (table types) and
+ row formats. For each table, you can decide which storage and
+ indexing method to use. Choosing the right table format for your
application may give you a big performance gain. See
<xref linkend="storage-engines"/>.
</para>
@@ -5277,7 +5266,7 @@
<literal>ROW_FORMAT=fixed</literal>.
</para>
</listitem>
-
+
<listitem>
<para>
The primary index of a table should be as short as possible.
@@ -5300,10 +5289,10 @@

<listitem>
<para>
- If it is very likely that a column has a unique prefix on the
- first number of characters, it is better to index only this
- prefix. MySQL supports an index on the leftmost part of a
- character column. Shorter indexes are faster not only
+ If it is very likely that a column has a unique prefix on
+ the first number of characters, it is better to index only
+ this prefix. MySQL supports an index on the leftmost part of
+ a character column. Shorter indexes are faster not only
because they take less disk space, but also because they
give you more hits in the index cache and thus fewer disk
seeks. See <xref linkend="server-parameters"/>.
@@ -5312,10 +5301,10 @@

<listitem>
<para>
- In some circumstances, it can be beneficial to split in two
- a table that is scanned very often. This is especially true
- if it is a dynamic format table and it is possible to use a
- smaller static format table that can be used to find the
+ In some circumstances, it can be beneficial to split in two
+ a table that is scanned very often. This is especially true
+ if it is a dynamic format table and it is possible to use a
+ smaller static format table that can be used to find the
relevant rows when scanning the table.
</para>
</listitem>
@@ -5525,7 +5514,7 @@

<para>
The manner in which MySQL uses indexes to improve query
- performance is discussed further in
+ performance is discussed further in
<xref linkend="mysql-indexes"/>.
</para>

@@ -5704,8 +5693,8 @@

<para>
If an index exists on <literal>(col1, col2, col3)</literal>,
- only the first two queries use the index. The third and fourth
- queries do involve indexed columns, but
+ only the first two queries use the index. The third and fourth
+ queries do involve indexed columns, but
<literal>(col2)</literal> and <literal>(col2, col3)</literal>
are not leftmost prefixes of <literal>(col1, col2,
col3)</literal>.
@@ -5759,12 +5748,12 @@
<para>
The following <literal>SELECT</literal> statements do not use
indexes:
+ </para>

<programlisting>
SELECT * FROM <replaceable>tbl_name</replaceable> WHERE <replaceable>key_col</replaceable> LIKE '%Patrick%';
SELECT * FROM <replaceable>tbl_name</replaceable> WHERE <replaceable>key_col</replaceable> LIKE <replaceable>other_col</replaceable>;
</programlisting>
- </para>

<para>
In the first statement, the <literal>LIKE</literal> value begins
@@ -5773,13 +5762,17 @@
</para>

<para>
- MySQL 4.0 and later versions perform an additional
- <literal>LIKE</literal> optimization. If you use <literal>...
+ MySQL 4.0 and later versions perform an additional
+ <literal>LIKE</literal> optimization. If you use <literal>...
LIKE '%<replaceable>string</replaceable>%'</literal> and
<replaceable>string</replaceable> is longer than three
- characters, MySQL uses the <firstterm>Turbo Boyer-Moore
- algorithm</firstterm> to initialize the pattern for the string
- and then uses this pattern to perform the search more quickly.
+ characters, MySQL uses the
+
+ <firstterm>Turbo Boyer-Moore
+ algorithm</firstterm>
+
+ to initialize the pattern for the string and then uses this
+ pattern to perform the search more quickly.
</para>

<indexterm type="function">
@@ -5799,14 +5792,15 @@
</para>

<para>
- Any index that does not span all <literal>AND</literal> levels in
- the <literal>WHERE</literal> clause is not used to optimize the
- query. In other words, to be able to use an index, a prefix of
- the index must be used in every <literal>AND</literal> group.
+ Any index that does not span all <literal>AND</literal> levels
+ in the <literal>WHERE</literal> clause is not used to optimize
+ the query. In other words, to be able to use an index, a prefix
+ of the index must be used in every <literal>AND</literal> group.
</para>

<para>
The following <literal>WHERE</literal> clauses use indexes:
+ </para>

<programlisting>
... WHERE <replaceable>index_part1</replaceable>=1 AND <replaceable>index_part2</replaceable>=2 AND <replaceable>other_column</replaceable>=3
@@ -5817,7 +5811,6 @@
/* Can use index on <replaceable>index1</replaceable> but not on <replaceable>index2</replaceable> or <replaceable>index3</replaceable> */
... WHERE <replaceable>index1</replaceable>=1 AND <replaceable>index2</replaceable>=2 OR <replaceable>index1</replaceable>=3 AND <replaceable>index3</replaceable>=3;
</programlisting>
- </para>

<para>
These <literal>WHERE</literal> clauses do
@@ -5921,11 +5914,17 @@

<listitem>
<para>
- For index blocks, a special structure called the
- <firstterm>key cache</firstterm> (or <firstterm>key
- buffer</firstterm>) is maintained. The structure contains a
- number of block buffers where the most-used index blocks are
- placed.
+ For index blocks, a special structure called the
+
+ <firstterm>key cache</firstterm>
+
+ (or
+
+ <firstterm>key
+ buffer</firstterm>
+
+ ) is maintained. The structure contains a number of block
+ buffers where the most-used index blocks are placed.
</para>
</listitem>

@@ -5969,7 +5968,7 @@
<literal>ISAM</literal> table use has been decreasing since
MySQL 3.23 when <literal>MyISAM</literal> was introduced. MySQL
4.1 carries this trend further; the <literal>ISAM</literal>
- storage engine is disabled by default. (Subsequent MySQL release
+ storage engine is disabled by default. (Subsequent MySQL release
series have no support at all for <literal>ISAM</literal>.)
</para>

@@ -6026,15 +6025,21 @@
</para>

<para>
- Usually the server follows an <firstterm>LRU (Least Recently
- Used)</firstterm> strategy: When choosing a block for
- replacement, it selects the least recently used index block. To
- make this choice easier, the key cache module maintains a
- special queue (<firstterm>LRU chain</firstterm>) of all used
- blocks. When a block is accessed, it is placed at the end of the
- queue. When blocks need to be replaced, blocks at the beginning
- of the queue are the least recently used and become the first
- candidates for eviction.
+ Usually the server follows an
+
+ <firstterm>LRU (Least Recently
+ Used)</firstterm>
+
+ strategy: When choosing a block for replacement, it selects the
+ least recently used index block. To make this choice easier, the
+ key cache module maintains a special queue (
+
+ <firstterm>LRU chain</firstterm>
+
+ ) of all used blocks. When a block is accessed, it is placed at
+ the end of the queue. When blocks need to be replaced, blocks at
+ the beginning of the queue are the least recently used and
+ become the first candidates for eviction.
</para>

<section id="shared-key-cache">
@@ -6067,7 +6072,7 @@

<listitem>
<para>
- A buffer being updated causes threads that need to use it
+ A buffer being updated causes threads that need to use it
to wait until the update is complete.
</para>
</listitem>
@@ -6160,8 +6165,9 @@
</programlisting>

<para>
- Note that you cannot destroy the default key cache. Any
+ Note that you cannot destroy the default key cache. Any
attempt to do this will be ignored:
+ </para>

<programlisting>
mysql> <userinput>set global key_buffer_size = 0;</userinput>
@@ -6173,7 +6179,6 @@
| key_buffer_size | 8384512 |
+-----------------+---------+
</programlisting>
- </para>

<para>
Key cache variables are structured system variables that have
@@ -6353,10 +6358,10 @@
The threshold value prescribes that, for a key cache
containing <replaceable>N</replaceable> blocks, the block at
the beginning of the hot sub-chain not accessed within the
- last <literal><replaceable>N</replaceable> *
- key_cache_age_threshold / 100</literal> hits is to be moved to
- the beginning of the warm sub-chain. It then becomes the first
- candidate for eviction, because blocks for replacement always
+ last <literal><replaceable>N</replaceable> *
+ key_cache_age_threshold / 100</literal> hits is to be moved to
+ the beginning of the warm sub-chain. It then becomes the first
+ candidate for eviction, because blocks for replacement always
are taken from the beginning of the warm sub-chain.
</para>

@@ -6399,7 +6404,7 @@
Without preloading, the blocks are still placed into the key
cache as needed by queries. Although the blocks will stay in
the cache, because there are enough buffers for all of them,
- they are fetched from disk in random order, and not
+ they are fetched from disk in random order, and not
sequentially.
</para>

@@ -6847,7 +6852,7 @@
<listitem>
<para>
Use the <option>--skip-external-locking</option> MySQL
- option to avoid external locking. This option is turned on
+ option to avoid external locking. This option is turned on
by default as of MySQL 4.0. Before that, it is on by default
when compiling with MIT-pthreads, because
<literal>flock()</literal> is not fully supported by
@@ -7117,10 +7122,10 @@
</programlisting>

<para>
- If you are performing <literal>GROUP BY</literal> or
- <literal>ORDER BY</literal> operations on tables that are much
- larger than your available memory, you should increase the value
- of <literal>read_rnd_buffer_size</literal> to speed up the
+ If you are performing <literal>GROUP BY</literal> or
+ <literal>ORDER BY</literal> operations on tables that are much
+ larger than your available memory, you should increase the value
+ of <literal>read_rnd_buffer_size</literal> to speed up the
reading of rows following sorting operations.
</para>

@@ -7205,22 +7210,22 @@
On Linux, you get the fastest server when compiling with
<command>pgcc</command> and <option>-O3</option>. You need about
200MB memory to compile <filename>sql_yacc.cc</filename> with
- these options, because <command>gcc</command> or
- <command>pgcc</command> needs a large amount of memory to make
- all functions inline. You should also set
+ these options, because <command>gcc</command> or
+ <command>pgcc</command> needs a large amount of memory to make
+ all functions inline. You should also set
<literal>CXX=gcc</literal> when configuring MySQL to avoid
inclusion of the <literal>libstdc++</literal> library, which is
not needed. Note that with some versions of
- <command>pgcc</command>, the resulting executable runs only on
+ <command>pgcc</command>, the resulting executable runs only on
true Pentium processors, even if you use the compiler option
- indicating that you want it to work on all x586-type processors
+ indicating that you want it to work on all x586-type processors
(such as AMD).
</para>

<para>
- Simply by using a better compiler and better compiler options,
- you can obtain a 10-30% speed increase in your applications.
- This is particularly important if you compile the MySQL server
+ Simply by using a better compiler and better compiler options,
+ you can obtain a 10-30% speed increase in your applications.
+ This is particularly important if you compile the MySQL server
yourself.
</para>

@@ -7526,7 +7531,7 @@

<listitem>
<para>
- For each <literal>MyISAM</literal> or
+ For each <literal>MyISAM</literal> or
<literal>ISAM</literal> table that is opened, the index file
is opened once and the data file is opened once for each
concurrently running thread. For each concurrent thread, a
@@ -7717,16 +7722,14 @@
better, assuming that the disk is not used for other
purposes as well. See <xref linkend="symbolic-links"/>.
</para>
-
- <para>
- <indexterm type="concept">
- <primary>striping</primary>
- <secondary>defined</secondary>
- </indexterm>
- </para>
</listitem>

<listitem>
+ <indexterm type="concept">
+ <primary>striping</primary>
+ <secondary>defined</secondary>
+ </indexterm>
+
<para>
Striping
</para>
@@ -7734,14 +7737,14 @@
<para>
Striping means that you have many disks and put the first
block on the first disk, the second block on the second
- disk, and the <replaceable>N</replaceable>th block on the
- (<literal><replaceable>N</replaceable>
- mod number_of_disks</literal>) disk, and so on. This means if your normal data size is
- less than the stripe size (or perfectly aligned), you get
- much better performance. Striping is very dependent on the
- operating system and the stripe size, so benchmark your
- application with different stripe sizes. See
- <xref linkend="custom-benchmarks"/>.
+ disk, and the <replaceable>N</replaceable>th block on the
+ (<literal><replaceable>N</replaceable> mod
+ number_of_disks</literal>) disk, and so on. This means if
+ your normal data size is less than the stripe size (or
+ perfectly aligned), you get much better performance.
+ Striping is very dependent on the operating system and the
+ stripe size, so benchmark your application with different
+ stripe sizes. See <xref linkend="custom-benchmarks"/>.
</para>

<para>
@@ -7810,11 +7813,11 @@
</para>

<para>
- If you do not need to know when files were last accessed (which
- is not really useful on a database server), you can mount your
- filesystems with the <option>-o noatime</option> option. That
- skips updates to the last access time in inodes on the
- filesystem, which avoids some disk seeks.
+ If you do not need to know when files were last accessed
+ (which is not really useful on a database server), you can
+ mount your filesystems with the <option>-o noatime</option>
+ option. That skips updates to the last access time in inodes
+ on the filesystem, which avoids some disk seeks.
</para>

<para>
@@ -8070,15 +8073,15 @@
</itemizedlist>

<para>
- <literal>SHOW CREATE TABLE</literal> does not report if a table
- has symbolic links prior to MySQL 4.0.15. This is also true
- for <command>mysqldump</command>, which uses <literal>SHOW
- CREATE TABLE</literal> to generate <literal>CREATE
- TABLE</literal> statements.
+ <literal>SHOW CREATE TABLE</literal> does not report if a
+ table has symbolic links prior to MySQL 4.0.15. This is also
+ true for <command>mysqldump</command>, which uses
+ <literal>SHOW CREATE TABLE</literal> to generate
+ <literal>CREATE TABLE</literal> statements.
</para>

<para>
- Table symlink operations that are not supported up through
+ Table symlink operations that are not supported up through
MySQL 4.1:
</para>

@@ -8207,10 +8210,10 @@
</programlisting>

<para>
- On Windows, you can make a symbolic link to a MySQL database
- by creating a file in the data directory that contains the
+ On Windows, you can make a symbolic link to a MySQL database
+ by creating a file in the data directory that contains the
path to the destination directory. The file should be named
- <filename><replaceable>db_name</replaceable>.sym</filename>,
+ <filename><replaceable>db_name</replaceable>.sym</filename>,
where <replaceable>db_name</replaceable> is the database name.
</para>

@@ -8248,8 +8251,8 @@
<para>
After that, all tables created in the database
<literal>foo</literal> are created in
- <filename>D:\data\foo</filename>. <emphasis>Note that the
- symbolic link is not used if a directory with the same name as
+ <filename>D:\data\foo</filename>. <emphasis>Note that the
+ symbolic link is not used if a directory with the same name as
the database exists in the MySQL data directory</emphasis>.
</para>


--- 1.8/refman/mysql-optimization.xml 2005-08-10 05:43:11 -05:00
+++ 1.10/refman/mysql-optimization.xml 2005-08-15 14:12:17 -05:00
@@ -917,16 +917,16 @@

<itemizedlist>

- <indexterm type="concept">
- <primary>system table</primary>
- </indexterm>
+ <listitem>
+ <indexterm type="concept">
+ <primary>system table</primary>
+ </indexterm>

- <indexterm type="concept">
- <primary>tables</primary>
- <secondary>system</secondary>
- </indexterm>
+ <indexterm type="concept">
+ <primary>tables</primary>
+ <secondary>system</secondary>
+ </indexterm>

- <listitem>
<para>
<literal>system</literal>
</para>
@@ -935,20 +935,18 @@
The table has only one row (= system table). This is a
special case of the <literal>const</literal> join type.
</para>
-
- <para>
- <indexterm type="concept">
- <primary>constant table</primary>
- </indexterm>
-
- <indexterm type="concept">
- <primary>tables</primary>
- <secondary>constant</secondary>
- </indexterm>
- </para>
</listitem>

<listitem>
+ <indexterm type="concept">
+ <primary>constant table</primary>
+ </indexterm>
+
+ <indexterm type="concept">
+ <primary>tables</primary>
+ <secondary>constant</secondary>
+ </indexterm>
+
<para>
<literal>const</literal>
</para>
@@ -971,14 +969,12 @@
<literal>const</literal> table:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>tbl_name</replaceable> WHERE <replaceable>primary_key</replaceable>=1;

SELECT * FROM <replaceable>tbl_name</replaceable>
WHERE <replaceable>primary_key_part1</replaceable>=1 AND <replaceable>primary_key_part2</replaceable>=2;
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1010,7 +1006,6 @@
<replaceable>ref_table</replaceable>:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>ref_table</replaceable>,<replaceable>other_table</replaceable>
WHERE <replaceable>ref_table</replaceable>.<replaceable>key_column</replaceable>=<replaceable>other_table</replaceable>.<replaceable>column</replaceable>;
@@ -1019,7 +1014,6 @@
WHERE <replaceable>ref_table</replaceable>.<replaceable>key_column_part1</replaceable>=<replaceable>other_table</replaceable>.<replaceable>column</replaceable>
AND <replaceable>ref_table</replaceable>.<replaceable>key_column_part2</replaceable>=1;
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1039,9 +1033,7 @@
a good join type.
</para>

- <para>
<!-- Note: The "or <=>" applies only to ref, not to eq_ref. -->
- </para>

<para>
<literal>ref</literal> can be used for indexed columns
@@ -1055,7 +1047,6 @@
<replaceable>ref_table</replaceable>:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>ref_table</replaceable> WHERE <replaceable>key_column</replaceable>=<replaceable>expr</replaceable>;

@@ -1066,7 +1057,6 @@
WHERE <replaceable>ref_table</replaceable>.<replaceable>key_column_part1</replaceable>=<replaceable>other_table</replaceable>.<replaceable>column</replaceable>
AND <replaceable>ref_table</replaceable>.<replaceable>key_column_part2</replaceable>=1;
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1088,12 +1078,10 @@
<replaceable>ref_table</replaceable>:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>ref_table</replaceable>
WHERE <replaceable>key_column</replaceable>=<replaceable>expr</replaceable> OR <replaceable>key_column</replaceable> IS NULL;
</programlisting>
- </para>

<para>
See <xref linkend="is-null-optimization"/>.
@@ -1124,11 +1112,13 @@
<para>
This type replaces <literal>ref</literal> for some
<literal>IN</literal> subqueries of the following form:
+ </para>

<programlisting>
<replaceable>value</replaceable> IN (SELECT <replaceable>primary_key</replaceable> FROM <replaceable>single_table</replaceable> WHERE <replaceable>some_expr</replaceable>)
</programlisting>

+ <para>
<literal>unique_subquery</literal> is just an index
lookup function that replaces the subquery completely
for better efficiency.
@@ -1147,11 +1137,9 @@
non-unique indexes in subqueries of the following form:
</para>

- <para>
<programlisting>
<replaceable>value</replaceable> IN (SELECT <replaceable>key_column</replaceable> FROM <replaceable>single_table</replaceable> WHERE <replaceable>some_expr</replaceable>)
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1180,7 +1168,6 @@
operators:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>tbl_name</replaceable>
WHERE <replaceable>key_column</replaceable> = 10;
@@ -1194,7 +1181,6 @@
SELECT * FROM <replaceable>tbl_name</replaceable>
WHERE <replaceable>key_part1</replaceable>= 10 AND <replaceable>key_part2</replaceable> IN (10,20,30);
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1319,16 +1305,13 @@
constants are used with the <literal>key</literal> to select
rows from the table.
</para>
-
- <para>
-<!-- TODO: we don't seem to explain what ref values of "const", NULL, or -->
- </para>
-
- <para>
-<!-- @var{tbl_name.col_name} mean. -->
- </para>
</listitem>

+<!--
+ TODO: We do not seem to explain what ref values of "const", NULL,
+ or @var{tbl_name.col_name} mean.
+-->
+
<listitem>
<para>
<literal>rows</literal>
@@ -1382,12 +1365,10 @@
optimized this way:
</para>

- <para>
<programlisting>
SELECT * FROM t1 LEFT JOIN t2 ON t1.id=t2.id
WHERE t2.id IS NULL;
</programlisting>
- </para>

<para>
Assume that <literal>t2.id</literal> is defined as
@@ -2001,35 +1982,35 @@
<listitem>
<para>
Removal of unnecessary parentheses:
+ </para>

<programlisting>
((a AND b) AND c OR (((a AND b) AND (c AND d))))
-> (a AND b AND c) OR (a AND b AND c AND d)
</programlisting>
- </para>
</listitem>

<listitem>
<para>
Constant folding:
+ </para>

<programlisting>
(a<b AND b=c) AND a=5
-> b>5 AND b=c AND a=5
</programlisting>
- </para>
</listitem>

<listitem>
<para>
Constant condition removal (needed because of constant
folding):
+ </para>

<programlisting>
(B>=5 AND B=5) OR (B=6 AND 5=5) OR (B=7 AND 5=6)
-> B=5 OR B=6
</programlisting>
- </para>
</listitem>

<listitem>
@@ -4557,17 +4538,16 @@
important for you, you should consider using the table in
ways that avoid deleting rows. Another possibility is to run
<literal>OPTIMIZE TABLE</literal> after you have deleted a
- lot of rows.
- See <xref linkend="myisam-storage-engine"/>.
+ lot of rows. See <xref linkend="myisam-storage-engine"/>.
</para>
</listitem>

<listitem>
<para>
- To fix any compression issues that may have occurred
- with <literal>ARCHIVE</literal> tables
- you can always do an <literal>OPTIMIZE TABLE</literal>.
- See <xref linkend="archive-storage-engine"/>.
+ To fix any compression issues that may have occurred with
+ <literal>ARCHIVE</literal> tables you can always do an
+ <literal>OPTIMIZE TABLE</literal>. See
+ <xref linkend="archive-storage-engine"/>.
</para>
</listitem>

@@ -6153,12 +6133,12 @@
<para>
The following <literal>SELECT</literal> statements do not use
indexes:
+ </para>

<programlisting>
SELECT * FROM <replaceable>tbl_name</replaceable> WHERE <replaceable>key_col</replaceable> LIKE '%Patrick%';
SELECT * FROM <replaceable>tbl_name</replaceable> WHERE <replaceable>key_col</replaceable> LIKE <replaceable>other_col</replaceable>;
</programlisting>
- </para>

<para>
In the first statement, the <literal>LIKE</literal> value begins
@@ -6201,6 +6181,7 @@

<para>
The following <literal>WHERE</literal> clauses use indexes:
+ </para>

<programlisting>
... WHERE <replaceable>index_part1</replaceable>=1 AND <replaceable>index_part2</replaceable>=2 AND <replaceable>other_column</replaceable>=3
@@ -6211,7 +6192,6 @@
/* Can use index on <replaceable>index1</replaceable> but not on <replaceable>index2</replaceable> or <replaceable>index3</replaceable> */
... WHERE <replaceable>index1</replaceable>=1 AND <replaceable>index2</replaceable>=2 OR <replaceable>index1</replaceable>=3 AND <replaceable>index3</replaceable>=3;
</programlisting>
- </para>

<para>
These <literal>WHERE</literal> clauses do
@@ -6551,6 +6531,7 @@
<para>
Note that you cannot destroy the default key cache. An attempt
to do this will be ignored:
+ </para>

<programlisting>
mysql> <userinput>set global key_buffer_size = 0;</userinput>
@@ -6562,7 +6543,6 @@
| key_buffer_size | 8384512 |
+-----------------+---------+
</programlisting>
- </para>

<para>
Key cache variables are structured system variables that have
@@ -8190,16 +8170,14 @@
better, assuming that the disk is not used for other
purposes as well. See <xref linkend="symbolic-links"/>.
</para>
-
- <para>
- <indexterm type="concept">
- <primary>striping</primary>
- <secondary>defined</secondary>
- </indexterm>
- </para>
</listitem>

<listitem>
+ <indexterm type="concept">
+ <primary>striping</primary>
+ <secondary>defined</secondary>
+ </indexterm>
+
<para>
Striping
</para>

--- 1.4/refman-5.0/mysql-optimization.xml 2005-08-10 05:44:16 -05:00
+++ 1.6/refman-5.0/mysql-optimization.xml 2005-08-15 14:12:16 -05:00
@@ -925,16 +925,16 @@

<itemizedlist>

- <indexterm type="concept">
- <primary>system table</primary>
- </indexterm>
+ <listitem>
+ <indexterm type="concept">
+ <primary>system table</primary>
+ </indexterm>

- <indexterm type="concept">
- <primary>tables</primary>
- <secondary>system</secondary>
- </indexterm>
+ <indexterm type="concept">
+ <primary>tables</primary>
+ <secondary>system</secondary>
+ </indexterm>

- <listitem>
<para>
<literal>system</literal>
</para>
@@ -943,20 +943,18 @@
The table has only one row (= system table). This is a
special case of the <literal>const</literal> join type.
</para>
-
- <para>
- <indexterm type="concept">
- <primary>constant table</primary>
- </indexterm>
-
- <indexterm type="concept">
- <primary>tables</primary>
- <secondary>constant</secondary>
- </indexterm>
- </para>
</listitem>

<listitem>
+ <indexterm type="concept">
+ <primary>constant table</primary>
+ </indexterm>
+
+ <indexterm type="concept">
+ <primary>tables</primary>
+ <secondary>constant</secondary>
+ </indexterm>
+
<para>
<literal>const</literal>
</para>
@@ -979,14 +977,12 @@
<literal>const</literal> table:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>tbl_name</replaceable> WHERE <replaceable>primary_key</replaceable>=1;

SELECT * FROM <replaceable>tbl_name</replaceable>
WHERE <replaceable>primary_key_part1</replaceable>=1 AND <replaceable>primary_key_part2</replaceable>=2;
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1018,7 +1014,6 @@
<replaceable>ref_table</replaceable>:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>ref_table</replaceable>,<replaceable>other_table</replaceable>
WHERE <replaceable>ref_table</replaceable>.<replaceable>key_column</replaceable>=<replaceable>other_table</replaceable>.<replaceable>column</replaceable>;
@@ -1027,7 +1022,6 @@
WHERE <replaceable>ref_table</replaceable>.<replaceable>key_column_part1</replaceable>=<replaceable>other_table</replaceable>.<replaceable>column</replaceable>
AND <replaceable>ref_table</replaceable>.<replaceable>key_column_part2</replaceable>=1;
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1061,7 +1055,6 @@
<replaceable>ref_table</replaceable>:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>ref_table</replaceable> WHERE <replaceable>key_column</replaceable>=<replaceable>expr</replaceable>;

@@ -1072,7 +1065,6 @@
WHERE <replaceable>ref_table</replaceable>.<replaceable>key_column_part1</replaceable>=<replaceable>other_table</replaceable>.<replaceable>column</replaceable>
AND <replaceable>ref_table</replaceable>.<replaceable>key_column_part2</replaceable>=1;
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1094,12 +1086,10 @@
<replaceable>ref_table</replaceable>:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>ref_table</replaceable>
WHERE <replaceable>key_column</replaceable>=<replaceable>expr</replaceable> OR <replaceable>key_column</replaceable> IS NULL;
</programlisting>
- </para>

<para>
See <xref linkend="is-null-optimization"/>.
@@ -1130,11 +1120,13 @@
<para>
This type replaces <literal>ref</literal> for some
<literal>IN</literal> subqueries of the following form:
+ </para>

<programlisting>
<replaceable>value</replaceable> IN (SELECT <replaceable>primary_key</replaceable> FROM <replaceable>single_table</replaceable> WHERE <replaceable>some_expr</replaceable>)
</programlisting>

+ <para>
<literal>unique_subquery</literal> is just an index
lookup function that replaces the subquery completely
for better efficiency.
@@ -1153,11 +1145,9 @@
non-unique indexes in subqueries of the following form:
</para>

- <para>
<programlisting>
<replaceable>value</replaceable> IN (SELECT <replaceable>key_column</replaceable> FROM <replaceable>single_table</replaceable> WHERE <replaceable>some_expr</replaceable>)
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1186,7 +1176,6 @@
operators:
</para>

- <para>
<programlisting>
SELECT * FROM <replaceable>tbl_name</replaceable>
WHERE <replaceable>key_column</replaceable> = 10;
@@ -1200,7 +1189,6 @@
SELECT * FROM <replaceable>tbl_name</replaceable>
WHERE <replaceable>key_part1</replaceable>= 10 AND <replaceable>key_part2</replaceable> IN (10,20,30);
</programlisting>
- </para>
</listitem>

<listitem>
@@ -1328,7 +1316,7 @@
</listitem>

<!--
- TODO: We don't seem to explain what ref values of "const", NULL,
+ TODO: We do not seem to explain what ref values of "const", NULL,
or <replaceable>tbl_name.col_name</replaceable> mean.
-->

@@ -1385,12 +1373,10 @@
optimized this way:
</para>

- <para>
<programlisting>
SELECT * FROM t1 LEFT JOIN t2 ON t1.id=t2.id
WHERE t2.id IS NULL;
</programlisting>
- </para>

<para>
Assume that <literal>t2.id</literal> is defined as
@@ -2004,35 +1990,35 @@
<listitem>
<para>
Removal of unnecessary parentheses:
+ </para>

<programlisting>
((a AND b) AND c OR (((a AND b) AND (c AND d))))
-> (a AND b AND c) OR (a AND b AND c AND d)
</programlisting>
- </para>
</listitem>

<listitem>
<para>
Constant folding:
+ </para>

<programlisting>
(a<b AND b=c) AND a=5
-> b>5 AND b=c AND a=5
</programlisting>
- </para>
</listitem>

<listitem>
<para>
Constant condition removal (needed because of constant
folding):
+ </para>

<programlisting>
(B>=5 AND B=5) OR (B=6 AND 5=5) OR (B=7 AND 5=6)
-> B=5 OR B=6
</programlisting>
- </para>
</listitem>

<listitem>
@@ -3536,40 +3522,42 @@
the columns required for the query as well. This avoids reading
the rows twice. The <literal>filesort</literal> algorithm works
like this:
+ </para>

- <orderedlist>
+ <orderedlist>

- <listitem>
- <para>
- Read the rows that match the <literal>WHERE</literal>
- clause, as before.
- </para>
- </listitem>
+ <listitem>
+ <para>
+ Read the rows that match the <literal>WHERE</literal>
+ clause, as before.
+ </para>
+ </listitem>

- <listitem>
- <para>
- For each row, record a tuple of values consisting of the
- sort key value and row position, and also the columns
- required for the query.
- </para>
- </listitem>
+ <listitem>
+ <para>
+ For each row, record a tuple of values consisting of the
+ sort key value and row position, and also the columns
+ required for the query.
+ </para>
+ </listitem>

- <listitem>
- <para>
- Sort the tuples by sort key value
- </para>
- </listitem>
+ <listitem>
+ <para>
+ Sort the tuples by sort key value
+ </para>
+ </listitem>

- <listitem>
- <para>
- Retrieve the rows in sorted order, but read the required
- columns directly from the sorted tuples rather than by
- accessing the table a second time.
- </para>
- </listitem>
+ <listitem>
+ <para>
+ Retrieve the rows in sorted order, but read the required
+ columns directly from the sorted tuples rather than by
+ accessing the table a second time.
+ </para>
+ </listitem>

- </orderedlist>
+ </orderedlist>

+ <para>
This algorithm represents an improvement over that used in some
older versions of MySQL.
</para>
@@ -4507,17 +4495,16 @@
important for you, you should consider using the table in
ways that avoid deleting rows. Another possibility is to run
<literal>OPTIMIZE TABLE</literal> after you have deleted a
- lot of rows.
- See <xref linkend="myisam-storage-engine"/>.
+ lot of rows. See <xref linkend="myisam-storage-engine"/>.
</para>
</listitem>

<listitem>
<para>
- To fix any compression issues that may have occurred
- with <literal>ARCHIVE</literal> tables
- you can always do an <literal>OPTIMIZE TABLE</literal>.
- See <xref linkend="archive-storage-engine"/>.
+ To fix any compression issues that may have occurred with
+ <literal>ARCHIVE</literal> tables you can always do an
+ <literal>OPTIMIZE TABLE</literal>. See
+ <xref linkend="archive-storage-engine"/>.
</para>
</listitem>

@@ -5154,42 +5141,42 @@

<para>
Options other than row-level or page-level locking:
+ </para>

- <itemizedlist>
+ <itemizedlist>

- <listitem>
- <para>
- Versioning (such as that used in MySQL for concurrent
- inserts) where it is possible to have one writer at the
- same time as many readers. This means that the database or
- table supports different views for the data depending on
- when access begins. Other common terms for this are
- <quote>time travel</quote>, <quote>copy on write</quote>,
- or <quote>copy on demand</quote>.
- </para>
- </listitem>
+ <listitem>
+ <para>
+ Versioning (such as that used in MySQL for concurrent
+ inserts) where it is possible to have one writer at the same
+ time as many readers. This means that the database or table
+ supports different views for the data depending on when
+ access begins. Other common terms for this are <quote>time
+ travel</quote>, <quote>copy on write</quote>, or <quote>copy
+ on demand</quote>.
+ </para>
+ </listitem>

- <listitem>
- <para>
- Copy on demand is in many cases superior to page-level or
- row-level locking. However, in the worst case, it can use
- much more memory than using normal locks.
- </para>
- </listitem>
+ <listitem>
+ <para>
+ Copy on demand is in many cases superior to page-level or
+ row-level locking. However, in the worst case, it can use
+ much more memory than using normal locks.
+ </para>
+ </listitem>

- <listitem>
- <para>
- Instead of using row-level locks, you can employ
- application-level locks, such as
- <literal>GET_LOCK()</literal> and
- <literal>RELEASE_LOCK()</literal> in MySQL. These are
- advisory locks, so they work only in well-behaved
- applications.
- </para>
- </listitem>
+ <listitem>
+ <para>
+ Instead of using row-level locks, you can employ
+ application-level locks, such as
+ <literal>GET_LOCK()</literal> and
+ <literal>RELEASE_LOCK()</literal> in MySQL. These are
+ advisory locks, so they work only in well-behaved
+ applications.
+ </para>
+ </listitem>

- </itemizedlist>
- </para>
+ </itemizedlist>

</section>

@@ -6133,12 +6120,12 @@
<para>
The following <literal>SELECT</literal> statements do
<emphasis>not</emphasis> use indexes:
+ </para>

<programlisting>
SELECT * FROM <replaceable>tbl_name</replaceable> WHERE <replaceable>key_col</replaceable> LIKE '%Patrick%';
SELECT * FROM <replaceable>tbl_name</replaceable> WHERE <replaceable>key_col</replaceable> LIKE <replaceable>other_col</replaceable>;
</programlisting>
- </para>

<para>
In the first statement, the <literal>LIKE</literal> value begins
@@ -6185,6 +6172,7 @@

<para>
The following <literal>WHERE</literal> clauses use indexes:
+ </para>

<programlisting>
... WHERE <replaceable>index_part1</replaceable>=1 AND <replaceable>index_part2</replaceable>=2 AND <replaceable>other_column</replaceable>=3
@@ -6195,7 +6183,6 @@
/* Can use index on <replaceable>index1</replaceable> but not on <replaceable>index2</replaceable> or <replaceable>index3</replaceable> */
... WHERE <replaceable>index1</replaceable>=1 AND <replaceable>index2</replaceable>=2 OR <replaceable>index1</replaceable>=3 AND <replaceable>index3</replaceable>=3;
</programlisting>
- </para>

<para>
These <literal>WHERE</literal> clauses do
@@ -6523,6 +6510,7 @@
<para>
Note that you cannot destroy the default key cache. An attempt
to do this will be ignored:
+ </para>

<programlisting>
mysql> <userinput>set global key_buffer_size = 0;</userinput>
@@ -6534,7 +6522,6 @@
| key_buffer_size | 8384512 |
+-----------------+---------+
</programlisting>
- </para>

<para>
Key cache variables are structured system variables that have
@@ -8234,16 +8221,14 @@
better, assuming that the disk is not used for other
purposes as well. See <xref linkend="symbolic-links"/>.
</para>
-
- <para>
- <indexterm type="concept">
- <primary>striping</primary>
- <secondary>defined</secondary>
- </indexterm>
- </para>
</listitem>

<listitem>
+ <indexterm type="concept">
+ <primary>striping</primary>
+ <secondary>defined</secondary>
+ </indexterm>
+
<para>
Striping
</para>

--
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe: http://lists.mysql.com/internals?unsub=email***@***.com