AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-71848

cjones's questions

Martin Hope
cjones
Asked: 2021-03-03 17:57:36 +0800 CST

在导出或导入时更改目标架构?

  • 0

我通常对 SQL 转储执行以下操作:

pg_dump -U username -cOx database > dump.sql

然后使用以下命令将其还原到新数据库中:

psql -U username new_database < dump.sql

目前,这些database表不在public模式中,而是在为用户命名的模式中。没有理由。我认为它发生在几年前使用一个名字无法理解的实用程序从 MySQL 迁移到 PostgreSQL 时。

我想把所有东西都移到public. 我知道我可以通过编辑dump.sql.

导出或导入 SQL 转储时有没有办法做到这一点?

这是 PostgreSQL 13,顺便说一句。

postgresql
  • 1 个回答
  • 29 Views
Martin Hope
cjones
Asked: 2021-02-28 04:22:25 +0800 CST

使用 pg_dump 制作数据库的精确副本的正确方法是什么?

  • 4

基本上,我正在尝试制作一个 SQL 转储,它将制作数据库的精确副本:用户定义的函数、关系、约束、表、数据等。

这是可行的pg_dump还是psql需要使用?

我一直在使用pg_dump -U user -cOx database > pg.sql,但我并不完全清楚它是否捕获了所有内容。

我在pg_dump这里查看了所有的标志:

https://www.postgresql.org/docs/11/app-pgdump.html

我能想到的唯一一个可能会这样做,因为它并没有真正明确地说明,是-s --schema-only标志,它不包括数据。我对此很好,并pg_dump为数据运行了第二个,但我主要想确保我正在备份用户定义的函数、关系等。

postgresql backup
  • 1 个回答
  • 1181 Views
Martin Hope
cjones
Asked: 2021-01-12 08:47:28 +0800 CST

ForeignKey 设置说明更新相关字段

  • 0

考虑 PosgtreSQL 中的这两个表:

# report
+----+-------------+--------------------+
| id | report_name | report_description |
+----+-------------+--------------------+
| 1  | RPT         | ABCDEFGH           |
| 2  | TST         | LMNOPQRS           |
+----+-------------+--------------------+

# report_years
+----+--------------+-------------+------+
| id | report_id_fk | report_name | year |
+----+--------------+-------------+------+
| 11 | 1            | RPT         | 2019 |
| 12 | 1            | RPT         | 2020 |
| 13 | 2            | TST         | 2019 |
+----+--------------+-------------+------+
  1. 鉴于这report_id_fk是report_years表中的外键,没有办法CASCADE更新report_name基于report_id_fk?
  2. 它们必须是单独的外键吗?
  3. report_name甚至不应该放在report_years表中,因为它是多余的,应该用JOINto来查询report?
  4. 是否有可能有一个多字段外键约束,report_name并且year对于 a 来说是必需的CASCADE?

例如:

# report
+----+-------------+------+
| id | report_name | year |
+----+-------------+------+
| 1  | RPT         | 2018 |
| 2  | RPT         | 2019 |
| 3  | RPT         | 2020 |
+----+-------------+------+

# report_details
+----+-----------+----------------+---------+---------+
| id | report_id | report_name_fk | year_fk | details |
+----+-----------+----------------+---------+---------+
| 11 | 1         | RPT            | 2018    | ABC     |
| 12 | 2         | RPT            | 2019    | DEF     |
| 13 | 3         | RPT            | 2020    | GHI     |
+----+-----------+----------------+---------+---------+
  1. 如果我想更改report_namefor year = 2020in report,它CASCADE会report_details更新report_name_fk基于report_name_fkand year_fk?
  2. 或者(回到问题 1),我可以设置一个CASCADE可以更新report_name_fk的year_fkinreport_details吗?

我可以通过手册了解如何做到这一点UPDATE,但看看是否可以使用CASCADE. 或者,就像我认为的那样,这是多余的,应该避免,如果您需要知道report_name并year获得报告report_details,您应该只写一个查询JOIN。

postgresql foreign-key
  • 1 个回答
  • 21 Views
Martin Hope
cjones
Asked: 2020-04-09 14:31:11 +0800 CST

使用 DISTINCT 或 GROUP BY 对不在 SELECT 中的字段进行 ORDER BY 以获取不同的记录

  • 0

从这个查询工作的 MySQL 迁移:

SELECT DISTINCT
    code,
    title,
    country
FROM
    data_a
ORDER BY
    sortorder

基本上,获取一个列表并按sortorder不基于code、title或的定义的用户/公司对其进行排序country。

现在我在 Postgres 中,这个查询不起作用并得到:

ERROR:  for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 12:  sortorder
          ^
SQL state: 42P10
Character: 135

但是,这样做会返回重复项,因为此处未列出使整个记录唯一的其他字段。code我只想要,title或country中的唯一值sortorder。

我试图做一个子查询,以为我可以在子查询中对其进行排序并将其带入已经排序的父查询中,但它只是以非特定顺序出现......好吧,也许它是特别的,但它不是不是我们想要的顺序。

SELECT
    DISTINCT s.*
FROM
    (
        SELECT
            code,
            title,
            country
        FROM
            data_a
        GROUP BY
            code,
            title,
            country,
            sortorder
        ORDER BY
            sortorder
    ) s;

关于如何做到这一点的任何建议?

postgresql
  • 1 个回答
  • 22 Views
Martin Hope
cjones
Asked: 2020-03-29 13:24:49 +0800 CST

将 MySQL AES_DECRYPT() 转换为 Postgres 解密()

  • 1

我使用以下 MySQL 查询AES_DECRYPT():

SELECT * 
FROM data_tbl
WHERE AES_DECRYPT(data_point,'aBcDeF')='data_1';

我已经发现 Postgres 11 中的等价物是decrypt()(F.25.4. Raw Encryption Functions),查询看起来像这样:

SELECT * 
FROM data_tbl
AND decrypt(data_point,'aBcDeF','aes')='data_1';

至少,两者的文档让我相信它们是等价的。

数据从 MySQL 转储并导入 PostgreSQL。

  • MySQL 中的data-point字段是类型varbinary(255),值都显示BLOB在 MySQL Workbench 中。
  • Postgres 中的data_point字段是类型bytea,值都显示[binary data]在 pgAdmin 中。

我承认,我不确定这些数据类型是否等效。

MySQL 查询工作并根据他的条件查找记录。PostgreSQL 没有,尽管记录在那里。所以它似乎是三件事之一:

  1. 数据类型 ( varbinary(255)vs bytea) 不等价
  2. 数据不匹配 ( BLOBvs [binary data]) 不等价
  3. 函数 ( AES_DECRYPTvs decrypt()) 不等价

我确实尝试通过首先尝试解密 PostgreSQL 中的值,以查看它的可读格式:

SELECT decrypt(data_point, 'aBcDeF', 'aes') 
FROM data_tbl;

但这只是[binary data]为所有行返回。

然后我遇到了这个答案,使用convert_from如下:

SELECT convert_from(decrypt(data_point, 'aBcDeF', 'aes'), 'SQL_ASCII')
FROM data_tbl;

但是,我只是收到此错误:

ERROR:  invalid byte sequence for encoding "UTF8": 0xcf 0xf5
SQL state: 22021

所以在这一点上,我对如何解决主要问题感到困惑。主要问题是在 PostgreSQL 11 中进行等效AES_DECRYPT操作。最后一条错误消息不是什么大问题,但它可能与decrypt()不返回相同的结果有关。

有什么建议么?

mysql postgresql
  • 2 个回答
  • 1601 Views
Martin Hope
cjones
Asked: 2020-03-24 10:04:44 +0800 CST

我应该如何为这种情况备份 Postgres?

  • 0

所以我备份 Postgres 的方式是:

pg_dumpall -U eox-dev -h localhost --clean --file=/home/backups/postgres.sql

我想确保我有一个生产就绪的备份,除了表和数据之外,它还包含函数、关系、触发器。

我现在正在尝试将其在 Kubernetes 集群中恢复到具有不同名称的数据库中prod_db-> staging_db,但是得到FATAL: database "prod_db" does not exist. 我正在尝试将其恢复到staging_db这样才有意义。.sql确实声明的第一行之一CREATE DATABASE prod_db。我不是关于编辑.sql. 如果我必须这样做,我做错了什么。

进行此备份的正确方法是什么?

postgresql backup
  • 2 个回答
  • 43 Views
Martin Hope
cjones
Asked: 2017-09-23 10:41:52 +0800 CST

通过 PostgreSQL 9.6 提高 RAM 和 CPU 利用率

  • 7

我一直在数据库上运行一个函数,该函数将进入每个表,ALTER COLUMN在特定数据类型的所有列上,并CAST删除尾随零。大约 115 个表,从几千条记录到几十万条记录不等。它已经运行了将近 24 小时,我的近似计算直到完成时间约为 58 小时。

我已经htop起来并定期检查它。

我应该提一下,这是截至昨天的 CentOS 最小版的全新安装,实际上只有 PostgreSQL 9.6.5。两个四核 CPU 和 32GB 内存。

根据htop我的记忆620M/31.3G,它一次最多使用一个核心,从不真正同时使用其他核心。就 CPU 和 RAM 利用率而言,我似乎有很多空间。看来如果我可以正确设置 PostgreSQL 以利用更多的 CPU 和 RAM,像我现在运行的进程会运行得更快。也许我错了。

有哪些可以调整的设置,无论是在 Postgres 还是在 CentOS 中,以提高利用率?

我postgresql.conf的几乎是默认设置:

# RESOURCE USAGE (except WAL)
#------------------------------------------------------------------------------

# - Memory -

shared_buffers = 128MB                  # min 128kB
                                        # (change requires restart)
#huge_pages = try                       # on, off, or try
                                        # (change requires restart)
#temp_buffers = 8MB                     # min 800kB
#max_prepared_transactions = 0          # zero disables the feature
                                        # (change requires restart)
# Caution: it is not advisable to set max_prepared_transactions nonzero unless
# you actively intend to use prepared transactions.
#work_mem = 4MB                         # min 64kB
#maintenance_work_mem = 64MB            # min 1MB
#replacement_sort_tuples = 150000       # limits use of replacement selection sort
#autovacuum_work_mem = -1               # min 1MB, or -1 to use maintenance_work_mem
#max_stack_depth = 2MB                  # min 100kB
dynamic_shared_memory_type = posix      # the default is the first option
                                        # supported by the operating system:
                                        #   posix
                                        #   sysv
                                        #   windows
                                        #   mmap
                                        # use none to disable dynamic shared memory
                                        # (change requires restart)

# - Disk -

#temp_file_limit = -1                   # limits per-process temp file space
                                        # in kB, or -1 for no limit

# - Kernel Resource Usage -

#max_files_per_process = 1000           # min 25
                                        # (change requires restart)
#shared_preload_libraries = ''          # (change requires restart)

# - Cost-Based Vacuum Delay -

#vacuum_cost_delay = 0                  # 0-100 milliseconds
#vacuum_cost_page_hit = 1               # 0-10000 credits
#vacuum_cost_page_miss = 10             # 0-10000 credits
#vacuum_cost_page_dirty = 20            # 0-10000 credits
#vacuum_cost_limit = 200                # 1-10000 credits

# - Background Writer -

#bgwriter_delay = 200ms                 # 10-10000ms between rounds
#bgwriter_lru_maxpages = 100            # 0-1000 max buffers written/round
#bgwriter_lru_multiplier = 2.0          # 0-10.0 multiplier on buffers scanned/round
#bgwriter_flush_after = 512kB           # measured in pages, 0 disables

# - Asynchronous Behavior -

#effective_io_concurrency = 1           # 1-1000; 0 disables prefetching
#max_worker_processes = 8               # (change requires restart)
#max_parallel_workers_per_gather = 0    # taken from max_worker_processes
#old_snapshot_threshold = -1            # 1min-60d; -1 disables; 0 is immediate
                                        # (change requires restart)
#backend_flush_after = 0                # measured in pages, 0 disables


#------------------------------------------------------------------------------
# WRITE AHEAD LOG
#------------------------------------------------------------------------------

# - Settings -

#wal_level = minimal                    # minimal, replica, or logical
                                        # (change requires restart)
#fsync = on                             # flush data to disk for crash safety
                                                # (turning this off can cause
                                                # unrecoverable data corruption)
#synchronous_commit = on                # synchronization level;
                                        # off, local, remote_write, remote_apply, or on
#wal_sync_method = fsync                # the default is the first option
                                        # supported by the operating system:
                                        #   open_datasync
                                        #   fdatasync (default on Linux)
                                        #   fsync
                                        #   fsync_writethrough
                                        #   open_sync
#full_page_writes = on                  # recover from partial page writes
#wal_compression = off                  # enable compression of full-page writes
#wal_log_hints = off                    # also do full page writes of non-critical updates
                                        # (change requires restart)
#wal_buffers = -1                       # min 32kB, -1 sets based on shared_buffers
                                        # (change requires restart)
#wal_writer_delay = 200ms               # 1-10000 milliseconds
#wal_writer_flush_after = 1MB           # measured in pages, 0 disables

#commit_delay = 0                       # range 0-100000, in microseconds
#commit_siblings = 5                    # range 1-1000

# - Checkpoints -

#checkpoint_timeout = 5min              # range 30s-1d
#max_wal_size = 1GB
#min_wal_size = 80MB
#checkpoint_completion_target = 0.5     # checkpoint target duration, 0.0 - 1.0
#checkpoint_flush_after = 256kB         # measured in pages, 0 disables
#checkpoint_warning = 30s               # 0 disables

# - Archiving -

#archive_mode = off             # enables archiving; off, on, or always
                                # (change requires restart)
#archive_command = ''           # command to use to archive a logfile segment
                                # placeholders: %p = path of file to archive
                                #               %f = file name only
                                # e.g. 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'
#archive_timeout = 0            # force a logfile segment switch after this
                                # number of seconds; 0 disables


#------------------------------------------------------------------------------
# REPLICATION
#------------------------------------------------------------------------------

# - Sending Server(s) -

# Set these on the master and on any standby that will send replication data.

#max_wal_senders = 0            # max number of walsender processes
                                # (change requires restart)
#wal_keep_segments = 0          # in logfile segments, 16MB each; 0 disables
#wal_sender_timeout = 60s       # in milliseconds; 0 disables

#max_replication_slots = 0      # max number of replication slots
                                # (change requires restart)
#track_commit_timestamp = off   # collect timestamp of transaction commit
                                # (change requires restart)

# - Master Server -

# These settings are ignored on a standby server.

#synchronous_standby_names = '' # standby servers that provide sync rep
                                # number of sync standbys and comma-separated list of application_name
                                # from standby(s); '*' = all
#vacuum_defer_cleanup_age = 0   # number of xacts by which cleanup is delayed

# - Standby Servers -

# These settings are ignored on a master server.

#hot_standby = off                      # "on" allows queries during recovery
                                        # (change requires restart)
#max_standby_archive_delay = 30s        # max delay before canceling queries
                                        # when reading WAL from archive;
                                        # -1 allows indefinite delay
#max_standby_streaming_delay = 30s      # max delay before canceling queries
                                        # when reading streaming WAL;
                                        # -1 allows indefinite delay
#wal_receiver_status_interval = 10s     # send replies at least this often
                                        # 0 disables
#hot_standby_feedback = off             # send info from standby to prevent
                                        # query conflicts
#wal_receiver_timeout = 60s             # time that receiver waits for
                                        # communication from master
                                        # in milliseconds; 0 disables
#wal_retrieve_retry_interval = 5s       # time to wait before retrying to
                                        # retrieve WAL after a failed attempt


#------------------------------------------------------------------------------
# QUERY TUNING
#------------------------------------------------------------------------------

# - Planner Method Configuration -

#enable_bitmapscan = on
#enable_hashagg = on
#enable_hashjoin = on
#enable_indexscan = on
#enable_indexonlyscan = on
#enable_material = on
#enable_mergejoin = on
#enable_nestloop = on
#enable_seqscan = on
#enable_sort = on
#enable_tidscan = on

# - Planner Cost Constants -

#seq_page_cost = 1.0                    # measured on an arbitrary scale
#random_page_cost = 4.0                 # same scale as above
#cpu_tuple_cost = 0.01                  # same scale as above
#cpu_index_tuple_cost = 0.005           # same scale as above
#cpu_operator_cost = 0.0025             # same scale as above
#parallel_tuple_cost = 0.1              # same scale as above
#parallel_setup_cost = 1000.0   # same scale as above
#min_parallel_relation_size = 8MB
#effective_cache_size = 4GB

# - Genetic Query Optimizer -

#geqo = on
#geqo_threshold = 12
#geqo_effort = 5                        # range 1-10
#geqo_pool_size = 0                     # selects default based on effort
#geqo_generations = 0                   # selects default based on effort
#geqo_selection_bias = 2.0              # range 1.5-2.0
#geqo_seed = 0.0                        # range 0.0-1.0

# - Other Planner Options -

#default_statistics_target = 100        # range 1-10000
#constraint_exclusion = partition       # on, off, or partition
#cursor_tuple_fraction = 0.1            # range 0.0-1.0
#from_collapse_limit = 8
#join_collapse_limit = 8                # 1 disables collapsing of explicit
                                        # JOIN clauses
#force_parallel_mode = off


#------------------------------------------------------------------------------
# ERROR REPORTING AND LOGGING
#------------------------------------------------------------------------------

# - Where to Log -

log_destination = 'stderr'              # Valid values are combinations of
                                        # stderr, csvlog, syslog, and eventlog,
                                        # depending on platform.  csvlog
                                        # requires logging_collector to be on.

# This is used when logging to stderr:
logging_collector = on                  # Enable capturing of stderr and csvlog
                                        # into log files. Required to be on for
                                        # csvlogs.
                                        # (change requires restart)

# These are only used if logging_collector is on:
log_directory = 'pg_log'                # directory where log files are written,
                                        # can be absolute or relative to PGDATA
log_filename = 'postgresql-%a.log'      # log file name pattern,
                                        # can include strftime() escapes
#log_file_mode = 0600                   # creation mode for log files,
                                        # begin with 0 to use octal notation
log_truncate_on_rotation = on           # If on, an existing log file with the
                                        # same name as the new log file will be
                                        # truncated rather than appended to.
                                        # But such truncation only occurs on
                                        # time-driven rotation, not on restarts
                                        # or size-driven rotation.  Default is
                                        # off, meaning append to existing files
                                        # in all cases.
log_rotation_age = 1d                   # Automatic rotation of logfiles will
                                        # happen after that time.  0 disables.
log_rotation_size = 0                   # Automatic rotation of logfiles will
                                        # happen after that much log output.
                                        # 0 disables.

# These are relevant when logging to syslog:
#syslog_facility = 'LOCAL0'
#syslog_ident = 'postgres'
#syslog_sequence_numbers = on
#syslog_split_messages = on

# This is only relevant when logging to eventlog (win32):
# (change requires restart)
#event_source = 'PostgreSQL'

# - When to Log -

CLient_min_messages = notice            # values in order of decreasing detail:
                                        #   debug5
                                        #   debug4
                                        #   debug3
                                        #   debug2
                                        #   debug1
                                        #   log
                                        #   notice
                                        #   warning
                                        #   error

log_min_messages = warning              # values in order of decreasing detail:
                                        #   debug5
                                        #   debug4
                                        #   debug3
                                        #   debug2
                                        #   debug1
                                        #   info
                                        #   notice
                                        #   warning
                                        #   error
                                        #   log
                                        #   fatal
                                        #   panic

log_min_error_statement = error         # VALUEs in order of decreasing detail:
                                        #   debug5
                                        #   debug4
                                        #   debug3
                                        #   debug2
                                        #   debug1
                                        #   info
                                        #   notice
                                        #   warning
                                        #   error
                                        #   log
                                        #   fatal
                                        #   panic (effectively off)

#log_min_duration_statement = -1        # -1 is disabled, 0 logs all statements
                                        # and their durations, > 0 logs only
                                        # statements running at least this number
                                        # of milliseconds


# - What to Log -

#debug_print_parse = off
#debug_print_rewritten = off
#debug_print_plan = off
#debug_pretty_print = on
#log_checkpoints = off
log_connections = off
#log_disconnections = off
#log_duration = off
log_error_verbosity = default           # terse, default, or verbose messages
#log_hostname = off
log_line_prefix = '< %m > '                     # special values:
                                        #   %a = application name
                                        #   %u = user name
                                        #   %d = database name
                                        #   %r = remote host and port
                                        #   %h = remote host
                                        #   %p = process ID
                                        #   %t = timestamp without milliseconds
                                        #   %m = timestamp with milliseconds
                                        #   %n = timestamp with milliseconds (as a Unix epoch)
                                        #   %i = command tag
                                        #   %e = SQL state
                                        #   %c = session ID
                                        #   %l = session line number
                                        #   %s = session start timestamp
                                        #   %v = virtual transaction ID
                                        #   %x = transaction ID (0 if none)
                                        #   %q = stop here in non-session
                                        #        processes
                                        #   %% = '%'
                                        # e.g. '<%u%%%d> '
#log_lock_waits = off                   # log lock waits >= deadlock_timeout
#log_statement = 'none'                 # none, ddl, mod, all
#log_replication_commands = off
#log_temp_files = -1                    # log temporary files equal or larger
                                        # than the specified size in kilobytes;
                                        # -1 disables, 0 logs all temp files
log_timezone = 'US/Pacific'


# - Process Title -

#cluster_name = ''                      # added to process titles if nonempty
                                        # (change requires restart)
#update_process_title = on


#------------------------------------------------------------------------------
# RUNTIME STATISTICS
#------------------------------------------------------------------------------

# - Query/Index Statistics Collector -

#track_activities = on
#track_counts = on
#track_io_timing = off
#track_functions = none                 # none, pl, all
#track_activity_query_size = 1024       # (change requires restart)
#stats_temp_directory = 'pg_stat_tmp'


# - Statistics Monitoring -

#log_parser_stats = off
#log_planner_stats = off
#log_executor_stats = off
#log_statement_stats = off


#------------------------------------------------------------------------------
# AUTOVACUUM PARAMETERS
#------------------------------------------------------------------------------

#autovacuum = on                        # Enable autovacuum subprocess?  'on'
                                        # requires track_counts to also be on.
#log_autovacuum_min_duration = -1       # -1 disables, 0 logs all actions and
                                        # their durations, > 0 logs only
                                        # actions running at least this number
                                        # of milliseconds.
#autovacuum_max_workers = 3             # max number of autovacuum subprocesses
                                        # (change requires restart)
#autovacuum_naptime = 1min              # time between autovacuum runs
#autovacuum_vacuum_threshold = 50       # min number of row updates before
                                        # vacuum
#autovacuum_analyze_threshold = 50      # min number of row updates before
                                        # analyze
#autovacuum_vacuum_scale_factor = 0.2   # fraction of table size before vacuum
#autovacuum_analyze_scale_factor = 0.1  # fraction of table size before analyze
#autovacuum_freeze_max_age = 200000000  # maximum XID age before forced vacuum
                                        # (change requires restart)
#autovacuum_multixact_freeze_max_age = 400000000        # maximum multixact age
                                        # before forced vacuum
                                        # (change requires restart)
#autovacuum_vacuum_cost_delay = 20ms    # default vacuum cost delay for
                                        # autovacuum, in milliseconds;
                                        # -1 means use vacuum_cost_delay
#autovacuum_vacuum_cost_limit = -1      # default vacuum cost limit for
                                        # autovacuum, -1 means use
                                        # vacuum_cost_limit


#------------------------------------------------------------------------------
# CLIENT CONNECTION DEFAULTS
#------------------------------------------------------------------------------

# - Statement Behavior -

#search_path = '"$user", public'        # schema names
#default_tablespace = ''                # a tablespace name, '' uses the default
#temp_tablespaces = ''                  # a list of tablespace names, '' uses
                                        # only default tablespace
#check_function_bodies = on
#default_transaction_isolation = 'read committed'
#default_transaction_read_only = off
#default_transaction_deferrable = off
#session_replication_role = 'origin'
#statement_timeout = 0                  # in milliseconds, 0 is disabled
#lock_timeout = 0                       # in milliseconds, 0 is disabled
#idle_in_transaction_session_timeout = 0                # in milliseconds, 0 is disabled
#vacuum_freeze_min_age = 50000000
#vacuum_freeze_table_age = 150000000
#vacuum_multixact_freeze_min_age = 5000000
#vacuum_multixact_freeze_table_age = 150000000
#bytea_output = 'hex'                   # hex, escape
#xmlbinary = 'base64'
#xmloption = 'content'
#gin_fuzzy_search_limit = 0
#gin_pending_list_limit = 4MB

# - Locale and Formatting -

datestyle = 'iso, mdy'
#intervalstyle = 'postgres'
timezone = 'US/Pacific'
#timezone_abbreviations = 'Default'     # Select the set of available time zone
                                        # abbreviations.  Currently, there are
                                        #   Default
                                        #   Australia (historical usage)
                                        #   India
                                        # You can create your own file in
                                        # share/timezonesets/.
#extra_float_digits = 0                 # min -15, max 3
#client_encoding = sql_ascii            # actually, defaults to database
                                        # encoding

# These settings are initialized by initdb, but they can be changed.
lc_messages = 'en_US.UTF-8'                     # locale for system error message
                                        # strings
lc_monetary = 'en_US.UTF-8'                     # locale for monetary formatting
lc_numeric = 'en_US.UTF-8'                      # locale for number formatting
lc_time = 'en_US.UTF-8'                         # locale for time formatting

# default configuration for text search
default_text_search_config = 'pg_catalog.english'

# - Other Defaults -

#dynamic_library_path = '$libdir'
#local_preload_libraries = ''
#session_preload_libraries = ''


#------------------------------------------------------------------------------
# LOCK MANAGEMENT
#------------------------------------------------------------------------------

#deadlock_timeout = 1s
#max_locks_per_transaction = 64         # min 10
                                        # (change requires restart)
#max_pred_locks_per_transaction = 64    # min 10
                                        # (change requires restart)


#------------------------------------------------------------------------------
# VERSION/PLATFORM COMPATIBILITY
#------------------------------------------------------------------------------

# - Previous PostgreSQL Versions -

#array_nulls = on
#backslash_quote = safe_encoding        # on, off, or safe_encoding
#default_with_oids = off
#escape_string_warning = on
#lo_compat_privileges = off
#operator_precedence_warning = off
#quote_all_identifiers = off
#sql_inheritance = on
#standard_conforming_strings = on
#synchronize_seqscans = on

# - Other Platforms and Clients -

#transform_null_equals = off


#------------------------------------------------------------------------------
# ERROR HANDLING
#------------------------------------------------------------------------------

#exit_on_error = off                    # terminate session on any error?
#restart_after_crash = on               # reinitialize after backend crash?


#------------------------------------------------------------------------------
# CONFIG FILE INCLUDES
#------------------------------------------------------------------------------

# These options allow settings to be loaded from files other than the
# default postgresql.conf.

#include_dir = 'conf.d'                 # include files ending in '.conf' from
                                        # directory 'conf.d'
#include_if_exists = 'exists.conf'      # include file only if it exists
#include = 'special.conf'               # include file


#------------------------------------------------------------------------------
# CUSTOMIZED OPTIONS
#------------------------------------------------------------------------------

# Add settings for extensions here
postgresql optimization
  • 3 个回答
  • 24443 Views
Martin Hope
cjones
Asked: 2017-08-08 10:04:58 +0800 CST

pgAdmin 4 v1.6 将 PostgreSQL 二进制路径设置为远程服务器以清除“系统找不到指定的路径”。错误

  • 0

只是想知道如何将二进制路径分配给远程服务器。我的个人计算机上有 pgAdmin,但 PostgreSQL 所在的服务器 (CentOS) 位于不同的位置。

postgresql pgadmin-4
  • 1 个回答
  • 3886 Views
Martin Hope
cjones
Asked: 2016-02-04 11:18:42 +0800 CST

将 MySQL 表迁移到已经有相同表的新服务器?

  • 0

我们将 Web 服务器迁移到更新的服务器。当我们对新的进行测试时,我们同时运行旧的和新的。我们的客户和内部员工仍在生产中使用旧版本,因此比一周前拍摄快照并进行迁移时的新版本更新。所以我需要将旧服务器上的新数据迁移到新服务器上。完成此任务的最佳方法是什么?如果我执行 mysqldump 并导入到新服务器中,它会覆盖那里已有的数据吗?如果是这样就好了,只是担心它会重复记录。基本上只是想在系统上没有人时将旧服务器上的所有内容转储到新服务器上。

mysql migration
  • 2 个回答
  • 291 Views
Martin Hope
cjones
Asked: 2016-01-11 16:39:26 +0800 CST

试图了解自动增量主键如何比没有主键和其他一些主键问题更好

  • 1

我试图更好地理解主键,如何在表设计和查询中有效地使用它们。

首先,主键本身是否用在 WHERE 子句中?例如,如果我有一个名称表,并且对于姓氏以“A”开头的所有条目,主键设置为“A”,对于所有姓氏以“B”开头的条目,主键设置为“B”,等等。最好的做法是:

WHERE pk_field = 'B' AND last_name = 'Bluthe'

其次,我想了解自动递增主键如何比以下内容更好地提高性能:

SELECT last_name FROM names WHERE last_name = 'Bluthe'

如果这条记录的主键是 1247

WHERE pk_field = 1247

会好很多。在找到匹配项之前,任务是否仍会遍历该列中的每条记录。

primary-key
  • 1 个回答
  • 82 Views
Martin Hope
cjones
Asked: 2016-01-11 15:44:58 +0800 CST

对于软件应用程序,是否每个工作站都需要数据库驱动程序?

  • 2

真的只是一个新问题。在类似公司企业系统的情况下,最终用户正在对数据库执行连续读取和写入,在大多数情况下,似乎每个工作站都不需要正在使用的数据库的驱动程序。凭据正在通过软件传递到数据库 IP 和端口,我假设当一个新用户被添加到软件中时,它正在将它们添加到数据库中,并在此时分配他们的读/写权限。用户将他们的登录信息提供给软件,该软件用作他们对数据库进行读/写的凭据。

但是,如果我想从第三方软件(Excel 或其他软件)访问数据库,那么我确实需要数据库的驱动程序。我想我不确定这是为什么,并且想知道是否有人可以向我解释。

举个例子,我曾经工作过的一家公司使用过 IBM DB2。我们有一个以 DB2 作为数据库的企业系统。使用围绕它的软件,我不记得曾经需要它的驱动程序。当我们开始在 Excel 中为其编写自定义报告时,我需要 ODBC 驱动程序,就像任何其他需要 Excel -> DB2 连接的工作站一样。

database-design
  • 1 个回答
  • 84 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve