|
1 | 1 | <!-- |
2 | | -$PostgreSQL: pgsql/doc/src/sgml/perform.sgml,v 1.49 2004/12/23 23:07:38 tgl Exp $ |
| 2 | +$PostgreSQL: pgsql/doc/src/sgml/perform.sgml,v 1.50 2005/02/0307:12:37 neilc Exp $ |
3 | 3 | --> |
4 | 4 |
|
5 | 5 | <chapter id="performance-tips"> |
@@ -362,12 +362,13 @@ EXPLAIN ANALYZE SELECT * FROM tenk1 t1, tenk2 t2 WHERE t1.unique1 < 50 AND t1 |
362 | 362 | </para> |
363 | 363 |
|
364 | 364 | <para> |
365 | | - One component of the statistics is the total number of entries in each |
366 | | - table and index, as well as the number of disk blocks occupied by each |
367 | | - table and index. This information is kept in the table |
368 | | - <structname>pg_class</structname> in the columns <structfield>reltuples</structfield> |
369 | | - and <structfield>relpages</structfield>. We can look at it |
370 | | - with queries similar to this one: |
| 365 | + One component of the statistics is the total number of entries in |
| 366 | + each table and index, as well as the number of disk blocks occupied |
| 367 | + by each table and index. This information is kept in the table |
| 368 | + <link linkend="catalog-pg-class"><structname>pg_class</structname></link>, in |
| 369 | + the columns <structfield>reltuples</structfield> and |
| 370 | + <structfield>relpages</structfield>. We can look at it with |
| 371 | + queries similar to this one: |
371 | 372 |
|
372 | 373 | <screen> |
373 | 374 | SELECT relname, relkind, reltuples, relpages FROM pg_class WHERE relname LIKE 'tenk1%'; |
@@ -406,14 +407,16 @@ SELECT relname, relkind, reltuples, relpages FROM pg_class WHERE relname LIKE 't |
406 | 407 |
|
407 | 408 | <para> |
408 | 409 | Most queries retrieve only a fraction of the rows in a table, due |
409 | | - to having <literal>WHERE</> clauses that restrict the rows to be examined. |
410 | | - The planner thus needs to make an estimate of the |
411 | | - <firstterm>selectivity</> of <literal>WHERE</> clauses, that is, the fraction of |
412 | | - rows that match each condition in the <literal>WHERE</> clause. The information |
413 | | - used for this task is stored in the <structname>pg_statistic</structname> |
414 | | - system catalog. Entries in <structname>pg_statistic</structname> are |
415 | | - updated by <command>ANALYZE</> and <command>VACUUM ANALYZE</> commands |
416 | | - and are always approximate even when freshly updated. |
| 410 | + to having <literal>WHERE</> clauses that restrict the rows to be |
| 411 | + examined. The planner thus needs to make an estimate of the |
| 412 | + <firstterm>selectivity</> of <literal>WHERE</> clauses, that is, |
| 413 | + the fraction of rows that match each condition in the |
| 414 | + <literal>WHERE</> clause. The information used for this task is |
| 415 | + stored in the <link linkend="catalog-pg-statistic"><structname>pg_statistic</structname></link> |
| 416 | + system catalog. Entries in <structname>pg_statistic</structname> |
| 417 | + are updated by the <command>ANALYZE</> and <command>VACUUM |
| 418 | + ANALYZE</> commands and are always approximate even when freshly |
| 419 | + updated. |
417 | 420 | </para> |
418 | 421 |
|
419 | 422 | <indexterm> |
|