1
1
<!--
2
- $Header: /cvsroot/pgsql/doc/src/sgml/perform.sgml,v 1.19 2002/03/24 04:31:05 tgl Exp $
2
+ $Header: /cvsroot/pgsql/doc/src/sgml/perform.sgml,v 1.20 2002/03/24 17:11:37 tgl Exp $
3
3
-->
4
4
5
5
<chapter id="performance-tips">
@@ -116,7 +116,7 @@ SELECT * FROM pg_class WHERE relname = 'tenk1';
116
116
</para>
117
117
118
118
<para>
119
- Now let's modify the query to add a qualification clause :
119
+ Now let's modify the query to add a WHERE condition :
120
120
121
121
<programlisting>
122
122
regression=# EXPLAIN SELECT * FROM tenk1 WHERE unique1 < 1000;
@@ -142,14 +142,14 @@ regression=# EXPLAIN SELECT * FROM tenk1 WHERE unique1 < 1000;
142
142
</para>
143
143
144
144
<para>
145
- Modify the query to restrict the qualification even more:
145
+ Modify the query to restrict the condition even more:
146
146
147
147
<programlisting>
148
148
regression=# EXPLAIN SELECT * FROM tenk1 WHERE unique1 < 50;
149
149
QUERY PLAN
150
150
-------------------------------------------------------------------------------
151
151
Index Scan using tenk1_unique1 on tenk1 (cost=0.00..179.33 rows=49 width=148)
152
- Index Filter : (unique1 < 50)
152
+ Index Cond : (unique1 < 50)
153
153
</programlisting>
154
154
155
155
and you will see that if we make the WHERE condition selective
@@ -161,15 +161,15 @@ regression=# EXPLAIN SELECT * FROM tenk1 WHERE unique1 < 50;
161
161
</para>
162
162
163
163
<para>
164
- Add another condition to the qualification :
164
+ Add another clause to the WHERE condition :
165
165
166
166
<programlisting>
167
167
regression=# EXPLAIN SELECT * FROM tenk1 WHERE unique1 < 50 AND
168
168
regression-# stringu1 = 'xxx';
169
169
QUERY PLAN
170
170
-------------------------------------------------------------------------------
171
171
Index Scan using tenk1_unique1 on tenk1 (cost=0.00..179.45 rows=1 width=148)
172
- Index Filter : (unique1 < 50)
172
+ Index Cond : (unique1 < 50)
173
173
Filter: (stringu1 = 'xxx'::name)
174
174
</programlisting>
175
175
@@ -193,10 +193,10 @@ regression-# AND t1.unique2 = t2.unique2;
193
193
Nested Loop (cost=0.00..327.02 rows=49 width=296)
194
194
-> Index Scan using tenk1_unique1 on tenk1 t1
195
195
(cost=0.00..179.33 rows=49 width=148)
196
- Index Filter : (unique1 < 50)
196
+ Index Cond : (unique1 < 50)
197
197
-> Index Scan using tenk2_unique2 on tenk2 t2
198
198
(cost=0.00..3.01 rows=1 width=148)
199
- Index Filter : ("outer".unique2 = t2.unique2)
199
+ Index Cond : ("outer".unique2 = t2.unique2)
200
200
</programlisting>
201
201
</para>
202
202
@@ -208,7 +208,7 @@ regression-# AND t1.unique2 = t2.unique2;
208
208
affect row count of the outer scan. For the inner scan, the unique2 value of the
209
209
current
210
210
outer-scan tuple is plugged into the inner index scan
211
- to produce an index qualification like
211
+ to produce an index condition like
212
212
<literal>t2.unique2 = <replaceable>constant</replaceable></literal>. So we get the
213
213
same inner-scan plan and costs that we'd get from, say, <literal>explain select
214
214
* from tenk2 where unique2 = 42</literal>. The costs of the loop node are then set
@@ -246,7 +246,7 @@ regression-# AND t1.unique2 = t2.unique2;
246
246
-> Hash (cost=179.33..179.33 rows=49 width=148)
247
247
-> Index Scan using tenk1_unique1 on tenk1 t1
248
248
(cost=0.00..179.33 rows=49 width=148)
249
- Index Filter : (unique1 < 50)
249
+ Index Cond : (unique1 < 50)
250
250
</programlisting>
251
251
252
252
This plan proposes to extract the 50 interesting rows of <classname>tenk1</classname>
@@ -279,11 +279,11 @@ regression-# WHERE t1.unique1 < 50 AND t1.unique2 = t2.unique2;
279
279
-> Index Scan using tenk1_unique1 on tenk1 t1
280
280
(cost=0.00..179.33 rows=49 width=148)
281
281
(actual time=0.63..8.91 rows=50 loops=1)
282
- Index Filter : (unique1 < 50)
282
+ Index Cond : (unique1 < 50)
283
283
-> Index Scan using tenk2_unique2 on tenk2 t2
284
284
(cost=0.00..3.01 rows=1 width=148)
285
285
(actual time=0.29..0.32 rows=1 loops=50)
286
- Index Filter : ("outer".unique2 = t2.unique2)
286
+ Index Cond : ("outer".unique2 = t2.unique2)
287
287
Total runtime: 31.60 msec
288
288
</screen>
289
289
0 commit comments