|
1 | | -<!-- $PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.54 2007/06/03 17:05:52 tgl Exp $ --> |
| 1 | +<!-- $PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.55 2007/11/04 19:43:33 momjian Exp $ --> |
2 | 2 |
|
3 | 3 | <chapter id="managing-databases"> |
4 | 4 | <title>Managing Databases</title> |
@@ -344,156 +344,156 @@ dropdb <replaceable class="parameter">dbname</replaceable> |
344 | 344 | <primary>tablespace</primary> |
345 | 345 | </indexterm> |
346 | 346 |
|
347 | | - <para> |
348 | | - Tablespaces in <productname>PostgreSQL</> allow database administrators to |
349 | | - define locations in the file system where the files representing |
350 | | - database objects can be stored. Once created, a tablespace can be referred |
351 | | - to by name when creating database objects. |
352 | | - </para> |
| 347 | + <para> |
| 348 | + Tablespaces in <productname>PostgreSQL</> allow database administrators to |
| 349 | + define locations in the file system where the files representing |
| 350 | + database objects can be stored. Once created, a tablespace can be referred |
| 351 | + to by name when creating database objects. |
| 352 | + </para> |
353 | 353 |
|
354 | | - <para> |
355 | | - By using tablespaces, an administrator can control the disk layout |
356 | | - of a <productname>PostgreSQL</> installation. This is useful in at |
357 | | - least two ways. First, if the partition or volume on which the |
358 | | - cluster was initialized runs out of space and cannot be extended, |
359 | | - a tablespace can be created on a different partition and used |
360 | | - until the system can be reconfigured. |
361 | | - </para> |
| 354 | + <para> |
| 355 | + By using tablespaces, an administrator can control the disk layout |
| 356 | + of a <productname>PostgreSQL</> installation. This is useful in at |
| 357 | + least two ways. First, if the partition or volume on which the |
| 358 | + cluster was initialized runs out of space and cannot be extended, |
| 359 | + a tablespace can be created on a different partition and used |
| 360 | + until the system can be reconfigured. |
| 361 | + </para> |
362 | 362 |
|
363 | | - <para> |
364 | | - Second, tablespaces allow an administrator to use knowledge of the |
365 | | - usage pattern of database objects to optimize performance. For |
366 | | - example, an index which is very heavily used can be placed on a |
367 | | - very fast, highly available disk, such as an expensive solid state |
368 | | - device. At the same time a table storing archived data which is |
369 | | - rarely used or not performance critical could be stored on a less |
370 | | - expensive, slower disk system. |
371 | | - </para> |
| 363 | + <para> |
| 364 | + Second, tablespaces allow an administrator to use knowledge of the |
| 365 | + usage pattern of database objects to optimize performance. For |
| 366 | + example, an index which is very heavily used can be placed on a |
| 367 | + very fast, highly available disk, such as an expensive solid state |
| 368 | + device. At the same time a table storing archived data which is |
| 369 | + rarely used or not performance critical could be stored on a less |
| 370 | + expensive, slower disk system. |
| 371 | + </para> |
372 | 372 |
|
373 | | - <para> |
374 | | - To define a tablespace, use the <xref |
375 | | - linkend="sql-createtablespace" endterm="sql-createtablespace-title"> |
376 | | - command, for example:<indexterm><primary>CREATE TABLESPACE</></>: |
| 373 | + <para> |
| 374 | + To define a tablespace, use the <xref |
| 375 | + linkend="sql-createtablespace" endterm="sql-createtablespace-title"> |
| 376 | + command, for example:<indexterm><primary>CREATE TABLESPACE</></>: |
377 | 377 | <programlisting> |
378 | 378 | CREATE TABLESPACE fastspace LOCATION '/mnt/sda1/postgresql/data'; |
379 | 379 | </programlisting> |
380 | | - The location must be an existing, empty directory that is owned by |
381 | | - the <productname>PostgreSQL</> system user. All objects subsequently |
382 | | - created within the tablespace will be stored in files underneath this |
383 | | - directory. |
384 | | - </para> |
385 | | - |
386 | | - <note> |
387 | | - <para> |
388 | | - There is usually not much point in making more than one |
389 | | - tablespace per logical file system, since you cannot control the location |
390 | | - of individual files within a logical file system. However, |
391 | | - <productname>PostgreSQL</> does not enforce any such limitation, and |
392 | | - indeed it is not directly aware of the file system boundaries on your |
393 | | - system. It just stores files in the directories you tell it to use. |
394 | | - </para> |
395 | | - </note> |
| 380 | + The location must be an existing, empty directory that is owned by |
| 381 | + the <productname>PostgreSQL</> system user. All objects subsequently |
| 382 | + created within the tablespace will be stored in files underneath this |
| 383 | + directory. |
| 384 | + </para> |
396 | 385 |
|
| 386 | + <note> |
397 | 387 | <para> |
398 | | - Creation of the tablespace itself must be done as a database superuser, |
399 | | - but after that you can allow ordinary database users to make use of it. |
400 | | - To do that, grant them the <literal>CREATE</> privilege on it. |
| 388 | + There is usually not much point in making more than one |
| 389 | + tablespace per logical file system, since you cannot control the location |
| 390 | + of individual files within a logical file system. However, |
| 391 | + <productname>PostgreSQL</> does not enforce any such limitation, and |
| 392 | + indeed it is not directly aware of the file system boundaries on your |
| 393 | + system. It just stores files in the directories you tell it to use. |
401 | 394 | </para> |
| 395 | + </note> |
402 | 396 |
|
403 | | - <para> |
404 | | - Tables, indexes, and entire databases can be assigned to |
405 | | - particular tablespaces. To do so, a user with the <literal>CREATE</> |
406 | | - privilege on a given tablespace must pass the tablespace name as a |
407 | | - parameter to the relevant command. For example, the following creates |
408 | | - a table in the tablespace <literal>space1</>: |
| 397 | + <para> |
| 398 | + Creation of the tablespace itself must be done as a database superuser, |
| 399 | + but after that you can allow ordinary database users to make use of it. |
| 400 | + To do that, grant them the <literal>CREATE</> privilege on it. |
| 401 | + </para> |
| 402 | + |
| 403 | + <para> |
| 404 | + Tables, indexes, and entire databases can be assigned to |
| 405 | + particular tablespaces. To do so, a user with the <literal>CREATE</> |
| 406 | + privilege on a given tablespace must pass the tablespace name as a |
| 407 | + parameter to the relevant command. For example, the following creates |
| 408 | + a table in the tablespace <literal>space1</>: |
409 | 409 | <programlisting> |
410 | 410 | CREATE TABLE foo(i int) TABLESPACE space1; |
411 | 411 | </programlisting> |
412 | | - </para> |
| 412 | + </para> |
413 | 413 |
|
414 | | - <para> |
415 | | - Alternatively, use the <xref linkend="guc-default-tablespace"> parameter: |
| 414 | + <para> |
| 415 | + Alternatively, use the <xref linkend="guc-default-tablespace"> parameter: |
416 | 416 | <programlisting> |
417 | 417 | SET default_tablespace = space1; |
418 | 418 | CREATE TABLE foo(i int); |
419 | 419 | </programlisting> |
420 | | - When <varname>default_tablespace</> is set to anything but an empty |
421 | | - string, it supplies an implicit <literal>TABLESPACE</> clause for |
422 | | - <command>CREATE TABLE</> and <command>CREATE INDEX</> commands that |
423 | | - do not have an explicit one. |
424 | | - </para> |
| 420 | + When <varname>default_tablespace</> is set to anything but an empty |
| 421 | + string, it supplies an implicit <literal>TABLESPACE</> clause for |
| 422 | + <command>CREATE TABLE</> and <command>CREATE INDEX</> commands that |
| 423 | + do not have an explicit one. |
| 424 | + </para> |
425 | 425 |
|
426 | | - <para> |
427 | | - There is also a <xref linkend="guc-temp-tablespaces"> parameter, which |
428 | | - determines the placement of temporary tables and indexes, as well as |
429 | | - temporary files that are used for purposes such as sorting large data |
430 | | - sets. This can be a list of tablespace names, rather than only one, |
431 | | - so that the load associated with temporary objects can be spread over |
432 | | - multiple tablespaces. A random member of the list is picked each time |
433 | | - a temporary object is to be created. |
434 | | - </para> |
| 426 | + <para> |
| 427 | + There is also a <xref linkend="guc-temp-tablespaces"> parameter, which |
| 428 | + determines the placement of temporary tables and indexes, as well as |
| 429 | + temporary files that are used for purposes such as sorting large data |
| 430 | + sets. This can be a list of tablespace names, rather than only one, |
| 431 | + so that the load associated with temporary objects can be spread over |
| 432 | + multiple tablespaces. A random member of the list is picked each time |
| 433 | + a temporary object is to be created. |
| 434 | + </para> |
435 | 435 |
|
436 | | - <para> |
437 | | - The tablespace associated with a database is used to store the system |
438 | | - catalogs of that database. Furthermore, it is the default tablespace |
439 | | - used for tables, indexes, and temporary files created within the database, |
440 | | - if no <literal>TABLESPACE</> clause is given and no other selection is |
441 | | - specified by <varname>default_tablespace</> or |
442 | | - <varname>temp_tablespaces</> (as appropriate). |
443 | | - If a database is created without specifying a tablespace for it, |
444 | | - it uses the same tablespace as the template database it is copied from. |
445 | | - </para> |
| 436 | + <para> |
| 437 | + The tablespace associated with a database is used to store the system |
| 438 | + catalogs of that database. Furthermore, it is the default tablespace |
| 439 | + used for tables, indexes, and temporary files created within the database, |
| 440 | + if no <literal>TABLESPACE</> clause is given and no other selection is |
| 441 | + specified by <varname>default_tablespace</> or |
| 442 | + <varname>temp_tablespaces</> (as appropriate). |
| 443 | + If a database is created without specifying a tablespace for it, |
| 444 | + it uses the same tablespace as the template database it is copied from. |
| 445 | + </para> |
446 | 446 |
|
447 | | - <para> |
448 | | - Two tablespaces are automatically created by <literal>initdb</>. The |
449 | | - <literal>pg_global</> tablespace is used for shared system catalogs. The |
450 | | - <literal>pg_default</> tablespace is the default tablespace of the |
451 | | - <literal>template1</> and <literal>template0</> databases (and, therefore, |
452 | | - will be the default tablespace for other databases as well, unless |
453 | | - overridden by a <literal>TABLESPACE</> clause in <command>CREATE |
454 | | - DATABASE</>). |
455 | | - </para> |
| 447 | + <para> |
| 448 | + Two tablespaces are automatically created by <literal>initdb</>. The |
| 449 | + <literal>pg_global</> tablespace is used for shared system catalogs. The |
| 450 | + <literal>pg_default</> tablespace is the default tablespace of the |
| 451 | + <literal>template1</> and <literal>template0</> databases (and, therefore, |
| 452 | + will be the default tablespace for other databases as well, unless |
| 453 | + overridden by a <literal>TABLESPACE</> clause in <command>CREATE |
| 454 | + DATABASE</>). |
| 455 | + </para> |
456 | 456 |
|
457 | | - <para> |
458 | | - Once created, a tablespace can be used from any database, provided |
459 | | - the requesting user has sufficient privilege. This means that a tablespace |
460 | | - cannot be dropped until all objects in all databases using the tablespace |
461 | | - have been removed. |
462 | | - </para> |
| 457 | + <para> |
| 458 | + Once created, a tablespace can be used from any database, provided |
| 459 | + the requesting user has sufficient privilege. This means that a tablespace |
| 460 | + cannot be dropped until all objects in all databases using the tablespace |
| 461 | + have been removed. |
| 462 | + </para> |
463 | 463 |
|
464 | | - <para> |
465 | | - To remove an empty tablespace, use the <xref |
466 | | - linkend="sql-droptablespace" endterm="sql-droptablespace-title"> |
467 | | - command. |
468 | | - </para> |
| 464 | + <para> |
| 465 | + To remove an empty tablespace, use the <xref |
| 466 | + linkend="sql-droptablespace" endterm="sql-droptablespace-title"> |
| 467 | + command. |
| 468 | + </para> |
469 | 469 |
|
470 | | - <para> |
471 | | - To determine the set of existing tablespaces, examine the |
472 | | - <structname>pg_tablespace</> system catalog, for example |
| 470 | + <para> |
| 471 | + To determine the set of existing tablespaces, examine the |
| 472 | + <structname>pg_tablespace</> system catalog, for example |
473 | 473 | <synopsis> |
474 | 474 | SELECT spcname FROM pg_tablespace; |
475 | 475 | </synopsis> |
476 | | - The <xref linkend="app-psql"> program's <literal>\db</> meta-command |
477 | | - is also useful for listing the existing tablespaces. |
478 | | - </para> |
| 476 | + The <xref linkend="app-psql"> program's <literal>\db</> meta-command |
| 477 | + is also useful for listing the existing tablespaces. |
| 478 | + </para> |
479 | 479 |
|
480 | | - <para> |
481 | | - <productname>PostgreSQL</> makes use of symbolic links |
482 | | - to simplify the implementation of tablespaces. This |
483 | | - means that tablespaces can be used <emphasis>only</> on systems |
484 | | - that support symbolic links. |
485 | | - </para> |
| 480 | + <para> |
| 481 | + <productname>PostgreSQL</> makes use of symbolic links |
| 482 | + to simplify the implementation of tablespaces. This |
| 483 | + means that tablespaces can be used <emphasis>only</> on systems |
| 484 | + that support symbolic links. |
| 485 | + </para> |
486 | 486 |
|
487 | | - <para> |
488 | | - The directory <filename>$PGDATA/pg_tblspc</> contains symbolic links that |
489 | | - point to each of the non-built-in tablespaces defined in the cluster. |
490 | | - Although not recommended, it is possible to adjust the tablespace |
491 | | - layout by hand by redefining these links. Two warnings: do not do so |
492 | | - while the server is running; and after you restart the server, |
493 | | - update the <structname>pg_tablespace</> catalog to show the new |
494 | | - locations. (If you do not, <literal>pg_dump</> will continue to show |
495 | | - the old tablespace locations.) |
496 | | - </para> |
| 487 | + <para> |
| 488 | + The directory <filename>$PGDATA/pg_tblspc</> contains symbolic links that |
| 489 | + point to each of the non-built-in tablespaces defined in the cluster. |
| 490 | + Although not recommended, it is possible to adjust the tablespace |
| 491 | + layout by hand by redefining these links. Two warnings: do not do so |
| 492 | + while the server is running; and after you restart the server, |
| 493 | + update the <structname>pg_tablespace</> catalog to show the new |
| 494 | + locations. (If you do not, <literal>pg_dump</> will continue to show |
| 495 | + the old tablespace locations.) |
| 496 | + </para> |
497 | 497 |
|
498 | 498 | </sect1> |
499 | 499 | </chapter> |
0 commit comments