제가 사용하는 서버의 메모리는 8GB입니다. PostgreSQL에 대해 적절한 effective_cache_size 및 shared_buffers 구성 매개 변수를 설정했습니다.PostgreSQL은 캐싱에 메모리를 사용하지 않습니다.
allow_system_table_mods off
application_name
archive_command (disabled)
archive_mode off
archive_timeout 0
array_nulls on
authentication_timeout 1min
autovacuum on
autovacuum_analyze_scale_factor 0.1
autovacuum_analyze_threshold 50
autovacuum_freeze_max_age 200000000
autovacuum_max_workers 3
autovacuum_naptime 1min
autovacuum_vacuum_cost_delay 20ms
autovacuum_vacuum_cost_limit -1
autovacuum_vacuum_scale_factor 0.2
autovacuum_vacuum_threshold 50
backslash_quote safe_encoding
bgwriter_delay 200ms
bgwriter_lru_maxpages 100
bgwriter_lru_multiplier 2
block_size 8192
bonjour off
bonjour_name
bytea_output hex
check_function_bodies on
checkpoint_completion_target 0.5
checkpoint_segments 3
checkpoint_timeout 5min
checkpoint_warning 30s
client_encoding UTF8
client_min_messages notice
commit_delay 0
commit_siblings 5
config_file /etc/postgresql/9.1/main/postgresql.conf
constraint_exclusion partition
cpu_index_tuple_cost 0.005
cpu_operator_cost 0.0025
cpu_tuple_cost 0.01
cursor_tuple_fraction 0.1
custom_variable_classes
data_directory /var/lib/postgresql/9.1/main
DateStyle ISO, MDY
db_user_namespace off
deadlock_timeout 1s
debug_assertions off
debug_pretty_print on
debug_print_parse off
debug_print_plan off
debug_print_rewritten off
default_statistics_target 100
default_tablespace
default_text_search_config pg_catalog.english
default_transaction_deferrable off
default_transaction_isolation read committed
default_transaction_read_only off
default_with_oids off
dynamic_library_path $libdir
effective_cache_size 6GB
effective_io_concurrency 1
enable_bitmapscan on
enable_hashagg on
enable_hashjoin on
enable_indexscan on
enable_material on
enable_mergejoin on
enable_nestloop on
enable_seqscan on
enable_sort on
enable_tidscan on
escape_string_warning on
exit_on_error off
external_pid_file /var/run/postgresql/9.1-main.pid
extra_float_digits 0
from_collapse_limit 8
fsync on
full_page_writes on
geqo on
geqo_effort 5
geqo_generations 0
geqo_pool_size 0
geqo_seed 0
geqo_selection_bias 2
geqo_threshold 12
gin_fuzzy_search_limit 0
hba_file /etc/postgresql/9.1/main/pg_hba.conf
hot_standby off
hot_standby_feedback off
ident_file /etc/postgresql/9.1/main/pg_ident.conf
ignore_system_indexes off
integer_datetimes on
IntervalStyle postgres
join_collapse_limit 8
krb_caseins_users off
krb_server_keyfile FILE:/etc/postgresql-common/krb5.keytab
krb_srvname postgres
lc_collate en_US.UTF-8
lc_ctype en_US.UTF-8
lc_messages en_US.UTF-8
lc_monetary en_US.UTF-8
lc_numeric en_US.UTF-8
lc_time en_US.UTF-8
listen_addresses *
lo_compat_privileges off
local_preload_libraries
log_autovacuum_min_duration -1
log_checkpoints off
log_connections off
log_destination csvlog
log_directory pg_log
log_disconnections off
log_duration off
log_error_verbosity default
log_executor_stats off
log_file_mode 0600
log_filename postgresql-%Y-%m-%d_%H%M%S.log
log_hostname off
log_line_prefix %t
log_lock_waits off
log_min_duration_statement 2s
log_min_error_statement error
log_min_messages warning
log_parser_stats off
log_planner_stats off
log_rotation_age 1d
log_rotation_size 10MB
log_statement none
log_statement_stats off
log_temp_files -1
log_timezone Turkey
log_truncate_on_rotation off
logging_collector on
maintenance_work_mem 16MB
max_connections 100
max_files_per_process 1000
max_function_args 100
max_identifier_length 63
max_index_keys 32
max_locks_per_transaction 64
max_pred_locks_per_transaction 64
max_prepared_transactions 0
max_stack_depth 2MB
max_standby_archive_delay 30s
max_standby_streaming_delay 30s
max_wal_senders 0
password_encryption on
port 5432
post_auth_delay 0
pre_auth_delay 0
quote_all_identifiers off
random_page_cost 4
replication_timeout 1min
restart_after_crash on
search_path public, "$user", public
segment_size 1GB
seq_page_cost 1
server_encoding UTF8
server_version 9.1.13
server_version_num 90113
session_replication_role origin
shared_buffers 2GB
shared_preload_libraries
silent_mode off
sql_inheritance on
ssl on
ssl_ciphers ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH
ssl_renegotiation_limit 512MB
standard_conforming_strings on
statement_timeout 0
stats_temp_directory pg_stat_tmp
superuser_reserved_connections 3
synchronize_seqscans on
synchronous_commit on
synchronous_standby_names
syslog_facility local0
syslog_ident postgres
tcp_keepalives_count 9
tcp_keepalives_idle 7200
tcp_keepalives_interval 75
temp_buffers 8MB
temp_tablespaces
TimeZone Turkey
timezone_abbreviations Default
trace_notify off
trace_recovery_messages log
trace_sort off
track_activities on
track_activity_query_size 1024
track_counts on
track_functions none
transaction_deferrable off
transaction_isolation read committed
transaction_read_only off
transform_null_equals off
unix_socket_directory /var/run/postgresql
unix_socket_group
unix_socket_permissions 0777
update_process_title on
vacuum_cost_delay 0
vacuum_cost_limit 200
vacuum_cost_page_dirty 20
vacuum_cost_page_hit 1
vacuum_cost_page_miss 10
vacuum_defer_cleanup_age 0
vacuum_freeze_min_age 50000000
vacuum_freeze_table_age 150000000
wal_block_size 8192
wal_buffers 16MB
wal_keep_segments 0
wal_level minimal
wal_receiver_status_interval 10s
wal_segment_size 16MB
wal_sender_delay 1s
wal_sync_method fdatasync
wal_writer_delay 200ms
work_mem 16MB
xmlbinary base64
xmloption content
zero_damaged_pages off
내가 웹 사이트에 대한 백엔드 데이터베이스로 PostgreSQL을을 사용하여 다음은 show all;
쿼리 결과입니다. PostgreSQL에 대한 다양한 쿼리를 수행 할 수 있도록 웹 사이트에서 스트레스 테스트를 실행합니다. 필자는 시스템을 모니터하고 PostgreSQL이 일부 메모리를 사용하는 선택 쿼리에 대해 새 프로세스를 생성하고 데이터를 반환하며 자체를 종료시키는 것을 확인합니다. 메인 Postgresql 프로세스는 2GB 가상 메모리 (shared_buffers)를 사용하지만 캐시에서 볼 때 메모리에 영구 데이터가 없다는 것을 알 수 있습니다. 그것은 항상 약 78mb를 사용합니다. PostgreSQL은 운영체제 캐시를 많이 사용하지만, top
은 메모리 사용량이 매우 적음을 보여줍니다.
뭔가 문제가 있습니까?
아니요, 정상입니다. 'effective_cache_size'는 OS가 유지하려고하는 디스크 버퍼링 양에 대해 PG에 힌트를 시도합니다. (귀하의 shared_buffers + effective_cache_size는 다소 높지만 총 사용 가능 메모리보다 _ _ _ 있어야합니다.) 스와핑이 발생하는지 IOstat/vmstat를 모니터링하십시오. 그렇다면 설정을 1GB + 4GB 정도로 낮추십시오. random_page_cost를 낮은 값으로 설정하면 부피가 큰 쿼리 + 네트워크 디스크에 유용합니다. – wildplasser