ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • PostgreSQL System Catalog
    카테고리 없음 2019. 11. 22. 15:33

    효율적인 데이터베이스 관리를 위해 내부적인 catalog를 사용한다.

    catalog는 다른 RDBMS에서 data dictionary로 불리기도 한다. 

    system catalogs list

    Catalog Name Purpose
    ag_graph  graph information
    ag_label  label information
    pg_aggregate  aggregate functions
    pg_am  index access methods
    pg_amop  access method operators
    pg_amproc   access method support procedures
    pg_attrdef  column default values
    pg_attribute  table columns (“attributes”)
    pg_auth_members  authorization identifier membership relationships
    pg_authid  authorization identifiers (roles)

    pg_cast

    casts (data type conversions)
    pg_class tables, indexes, sequences, views (“relations”)
    pg_collation collations (locale information)
    pg_constraint check constraints, unique constraints, primary key constraints, foreign key constraints
    pg_conversion encoding conversion information
    pg_database databases within this database cluster
    pg_db_role_setting per-role and per-database settings
    pg_default_acl default privileges for object types
    pg_depend dependencies between database objects
    pg_description descriptions or comments on database objects
    pg_enum enum label and value definitions
    pg_event_trigger event triggers
    pg_extension installed extensions
    pg_foreign_data_wrapper foreign-data wrapper definitions
    pg_foreign_server foreign server definitions
    pg_foreign_table additional foreign table information
    pg_index additional index information
    pg_inherits  table inheritance hierarchy
    pg_init_privs  object initial privileges
    pg_language  languages for writing functions
    pg_largeobject  data pages for large objects
    pg_largeobject_metadata metadata for large objects
    pg_namespace  schemas
    pg_opclass  access method operator classes
    pg_operator  operators
    pg_opfamily access method operator families
    pg_pltemplate  template data for procedural languages
    pg_policy  row-security policies
    pg_proc  functions and procedures
    pg_range  information about range types
    pg_replication_origin  registered replication origins
    pg_rewrite  query rewrite rules
    pg_seclabel  security labels on database objects
    pg_shdepend  dependencies on shared objects
    pg_shdescription  comments on shared objects
    pg_shseclabel security labels on shared database objects
    pg_statistic planner statistics
    pg_tablespace  tablespaces within this database cluster
    pg_transform  transforms (data type to procedural language conversions)
    pg_trigger  triggers
    pg_ts_config  text search configurations
    pg_ts_config_map text search configurations' token mappings
    pg_ts_dict text search dictionaries
    pg_ts_parser  text search parsers
    pg_ts_template text search templates
    pg_type  data types
    pg_user_mapping  mappings of users to foreign servers

    system views list

    View Name

    Purpose

    pg_available_extensions

    available extensions

    pg_available_extension_versions

    available versions of extensions

    pg_config

    compile-time configuration parameters

    pg_cursors

    open cursors

    pg_file_settings

    summary of configuration file contents

    pg_group

    groups of database users

    pg_hba_file_rules

    summary of client authentication configuration file contents

    pg_indexes

    indexes

    pg_locks

    locks currently held or awaited

    pg_matviews

    materialized views

    pg_policies

    policies

    pg_prepared_statements

    prepared statements

    pg_prepared_xacts

    prepared transactions

    pg_publication_tables

    publications and their associated tables

    pg_replication_origin_status

    information about replication origins, including replication progress

    pg_replication_slots

    replication slot information

    pg_roles

    database roles

    pg_rules

    rules

    pg_seclabels

    security labels

    pg_sequences

    sequences

    pg_settings

    parameter settings

    pg_shadow

    database users

    pg_stats

    planner statistics

    pg_tables

    tables

    pg_timezone_abbrevs

    time zone abbreviations

    pg_timezone_names

    time zone names

    pg_user

    database users

    pg_user_mappings

    user mappings

    pg_views

    views

     

    다음은 주로 사용되는 system catalog 및 view에 대한 설명이다.

     

    ▶ System Catalogs (시스템 카탈로그)

    • pg_class (\dS)

      Table, Index, Sequence, View 에 대한 종합적인 정보를 담고 있다. 

      Name

      Type

      References

      Description

      relname

      name

       

      Name of the table, index, view, etc.

      relowner

      oid

      pg_authid.oid

      Owner of the relation

      relnatts

      int2

       

      Number of user columns in the relation (system columns not counted). There must be this many corresponding entries in pg_attribute. See also pg_attribute.attnum.
    • pg_constraint

      constraint에 대한 정보를 담고 있다.

      Name Type References Description
      conname name   Constraint name (not necessarily unique!)
      contype char   c = check constraint, f = foreign key constraint, p = primary key constraint, u = unique constraint, t = constraint trigger, x = exclusion constraint
    • pg_database (\l)

      해당 클러스터에 속한 database 정보를 담고 있다.

      Name Type References Description
      datname name   Database name
      datdba oid pg_authid.oid Owner of the database, usually the user who created it
      encoding int4   Character encoding for this database (pg_encoding_to_char() can translate this number to the encoding name)
      datcollate name   LC_COLLATE for this database
      datctype name   LC_CTYPE for this database
      datacl aclitem[]   Access privileges; see GRANT and REVOKE for details
    • pg_extension (\dx)

      해당 클러스터에 설치된 extension에 대한 정보를 담고 있다.

      Name Type References Description
      extname name   Name of the extension
      extowner oid pg_authid.oid Owner of the extension
      extversion text   Version name for the extension
    • pg_namespace (\du) 

       schema 정보를 담고 있다.

      Name Type References Description
      oid oid   Row identifier (hidden attribute; must be explicitly selected)
      nspname name   Name of the namespace
      nspowner oid pg_authid.oid Owner of the namespace
      nspacl aclitem[]   Access privileges; see GRANT and REVOKE for details
    • pg_tablespace (\db)

      해당 클러스터에 속한 tablespace에 대한 정보를 담고 있다.

      Name Type References Description
      spcname name   Tablespace name
      spcowner oid pg_authid.oid Owner of the tablespace, usually the user who created it

    Name

    ▶ System Views (시스템 뷰)

    • pg_available_extensions 

      사용 가능한 extension에 대한 정보를 담고 있다.

      Name Type Description
      name name Extension name
      default_version text Name of default version, or NULL if none is specified
      installed_version text Currently installed version of the extension, or NULL if not installed
      comment text Comment string from the extension's control file
    • pg_file_settings

      config file에 설정된 내용에 대한 정보를 담고 있다.

      Name Type Description
      sourcefile text Full path name of the configuration file
      sourceline integer Line number within the configuration file where the entry appears
      seqno integer Order in which the entries are processed (1..n)
      name text Configuration parameter name
      setting text Value to be assigned to the parameter
      applied boolean True if the value can be applied successfully
      error text If not null, an error message indicating why this entry could not be applied
    • pg_group

      데이터베이스 사용자 그룹에 대한 정보를 담고 있다.

      Name Type References Description
      groname name pg_authid.rolname Name of the group
      grosysid oid pg_authid.oid ID of this group
      grolist oid[] pg_authid.oid An array containing the IDs of the roles in this group
    • pg_indexes 

      인덱스 정보를 담고 있다.

      Name Type References Description
      schemaname name pg_namespace.nspname Name of schema containing table and index
      tablename name pg_class.relname Name of table the index is for
      indexname name pg_class.relname Name of index
      tablespace name pg_tablespace.spcname Name of tablespace containing index (null if default for database)
      indexdef text   Index definition (a reconstructed CREATE INDEX command)
    • pg_roles

      Database role에 대한 정보를 담고 있다.

      Name Type References Description
      rolname name   Role name
      rolsuper bool   Role has superuser privileges
      rolinherit bool   Role automatically inherits privileges of roles it is a member of
      rolcreaterole bool   Role can create more roles
      rolcreatedb bool   Role can create databases
      rolcanlogin bool   Role can log in. That is, this role can be given as the initial session authorization identifier
      rolreplication bool   Role is a replication role. A replication role can initiate replication connections and create and drop replication slots.
      rolconnlimit int4   For roles that can log in, this sets maximum number of concurrent connections this role can make. -1 means no limit.
      rolpassword text   Not the password (always reads as ********)
      rolbypassrls bool   Role bypasses every row level security policy
      oid oid pg_authid.oid ID of role
    • pg_settings 

      config parameter에 대한 정보를 담고 있다.

      Name Type Description
      name text Run-time configuration parameter name
      setting text Current value of the parameter
      unit text Implicit unit of the parameter
      boot_val text Parameter value assumed at server startup if the parameter is not otherwise set
      reset_val text Value that RESET would reset the parameter to in the current session
    • pg_shadow

      데이터베이스 사용자에 대한 정보를 담고 있다.

      Name Type References Description
      usename name pg_authid.rolname User name
      usesysid oid pg_authid.oid ID of this user
      usecreatedb bool   User can create databases
      usesuper bool   User is a superuser
      userepl bool   User can initiate streaming replication and put the system in and out of backup mode.
      usebypassrls bool   User bypasses every row level security policy
      passwd text   Password (possibly encrypted); null if none. See pg_authid for details of how encrypted passwords are stored.
    • pg_stats

      planner 통계정보를 담고 있다.

      Name Type References Description
      schemaname name pg_namespace.nspname Name of schema containing table
      tablename name pg_class.relname Name of table
      attname name pg_attribute.attname Name of the column described by this row
      inherited bool   If true, this row includes inheritance child columns, not just the values in the specified table
      null_frac real   Fraction of column entries that are null
      avg_width integer   Average width in bytes of column's entries
      n_distinct real   If greater than zero, the estimated number of distinct values in the column. If less than zero, the negative of the number of distinct values divided by the number of rows. (The negated form is used when ANALYZE believes that the number of distinct values is likely to increase as the table grows; the positive form is used when the column seems to have a fixed number of possible values.) For example, -1 indicates a unique column in which the number of distinct values is the same as the number of rows.
      most_common_vals anyarray   A list of the most common values in the column. (Null if no values seem to be more common than any others.)
      most_common_freqs real[]   A list of the frequencies of the most common values, i.e., number of occurrences of each divided by total number of rows. (Null when most_common_vals is.)
      histogram_bounds anyarray   A list of values that divide the column's values into groups of approximately equal population. The values in most_common_vals, if present, are omitted from this histogram calculation. (This column is null if the column data type does not have a < operator or if the most_common_vals list accounts for the entire population.)
      correlation real   Statistical correlation between physical row ordering and logical ordering of the column values. This ranges from -1 to +1. When the value is near -1 or +1, an index scan on the column will be estimated to be cheaper than when it is near zero, due to reduction of random access to the disk. (This column is null if the column data type does not have a < operator.)
      most_common_elems anyarray   A list of non-null element values most often appearing within values of the column. (Null for scalar types.)
      most_common_elem_freqs real[]   A list of the frequencies of the most common element values, i.e., the fraction of rows containing at least one instance of the given value. Two or three additional values follow the per-element frequencies; these are the minimum and maximum of the preceding per-element frequencies, and optionally the frequency of null elements. (Null when most_common_elems is.)
      elem_count_histogram real[]   A histogram of the counts of distinct non-null element values within the values of the column, followed by the average number of distinct non-null elements. (Null for scalar types.)
    • pg_tables

      Table에 대한 정보를 담고 있다.

      Name Type References Description
      schemaname name pg_namespace.nspname Name of schema containing table
      tablename name pg_class.relname Name of table
      tableowner name pg_authid.rolname Name of table's owner
      tablespace name pg_tablespace.spcname Name of tablespace containing table (null if default for database)
      hasindexes boolean pg_class.relhasindex True if table has (or recently had) any indexes
      hasrules boolean pg_class.relhasrules True if table has (or once had) rules
      hastriggers boolean pg_class.relhastriggers True if table has (or once had) triggers
      rowsecurity boolean pg_class.relrowsecurity True if row security is enabled on the table
    • pg_user

      데이터베이스 사용자에 대한 정보를 담고 있다.

      Name Type Description
      usename name User name
      usesysid oid ID of this user
      usecreatedb bool User can create databases
      usesuper bool User is a superuser
      userepl bool User can initiate streaming replication and put the system in and out of backup mode.
      usebypassrls bool User bypasses every row level security policy
      passwd text Not the password (always reads as ********)
      valuntil abstime Password expiry time (only used for password authentication)
      useconfig text[] Session defaults for run-time configuration variables
    • pg_views

      View에 대한 정보를 담고 있다.

      Name Type References Description
      schemaname name pg_namespace.nspname Name of schema containing view
      viewname name pg_class.relname Name of view
      viewowner name pg_authid.rolname Name of view's owner
      definition text   View definition (a reconstructed SELECT query)
Designed by Tistory.