#---------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#---------------------------------------------------------------------------

# - Connection Settings -

listen_addresses = '*'
port = 5432
max_connections = 20
superuser_reserved_connections = 2
#bonjour_name = ''

# - Security & Authentication -

authentication_timeout = 60
#ssl = off
password_encryption = on
# db_user_namespace = on


# - TCP Keepalives -
# see 'man 7 tcp' for details

#tcp_keepalives_idle = 0		# TCP_KEEPIDLE, in seconds;
					# 0 selects the system default
#tcp_keepalives_interval = 0		# TCP_KEEPINTVL, in seconds;
					# 0 selects the system default
#tcp_keepalives_count = 0		# TCP_KEEPCNT;
					# 0 selects the system default


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

# - Memory -

shared_buffers = 16000			# (16000 * 8 = 128MB)
#temp_buffers = 1000			# min 100, 8KB each
#max_prepared_transactions = 5		# can be 0 or more
work_mem = 3072				# (3MB por cliente)
maintenance_work_mem = 65536		# (64MB - vacuum)
max_stack_depth = 3072			# (3MB - pilha)


# - Background writer -

bgwriter_delay = 300
bgwriter_lru_percent = 2.0
bgwriter_lru_maxpages = 10
bgwriter_all_percent = 0.5
bgwriter_all_maxpages = 10


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

# - Planner Method Configuration -

#enable_hashagg = on
#enable_hashjoin = on
enable_indexscan = on
enable_mergejoin = on
enable_nestloop = on
enable_seqscan = on
enable_sort = on
#enable_tidscan = on

# - Planner Cost Constants -

effective_cache_size = 1000
random_page_cost = 4
cpu_tuple_cost = 0.01
cpu_index_tuple_cost = 0.001
cpu_operator_cost = 0.0025

# - Genetic Query Optimizer -

geqo = on
geqo_threshold = 7
geqo_effort = 6
geqo_pool_size = 200
geqo_generations = 200
geqo_selection_bias = 2.0

# - Other Planner Options -

default_statistics_target = 100
#constraint_exclusion = off
from_collapse_limit = 5
join_collapse_limit = 5


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

# - Where to Log -

# log_destination = 'stderr'

# This is used when logging to stderr:
# redirect_stderr = on

# log_line_prefix = '%r '			# Special values:
					#   %u = user name
					#   %d = database name
					#   %r = remote host and port
					#   %h = remote host
					#   %p = PID
					#   %t = timestamp (no milliseconds)
					#   %m = timestamp with milliseconds
					#   %i = command tag
					#   %c = session id
					#   %l = session line number
					#   %s = session start timestamp
					#   %x = transaction id
					#   %q = stop here in non-session 
					#        processes
					#   %% = '%'
					# e.g. '<%u%%%d> '


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

# - Query/Index Statistics Collector -

stats_start_collector = on
#stats_command_string = off
#stats_block_level = off
stats_row_level = on
#stats_reset_on_server_start = off


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

# - Statement Behavior -

#search_path = '$user,public'
#default_tablespace = ''

#check_function_bodies = on
default_transaction_isolation = 'serializable'
#default_transaction_read_only = off
#statement_timeout = 0

# - Locale and Formatting -

datestyle = 'European'
#timezone = unknown
#australian_timezones = off
#extra_float_digits = 0	
#client_encoding = sql_ascii

lc_messages = 'C'
lc_monetary = 'C'
lc_numeric = 'C'
lc_time = 'C'

# - Other Defaults -

#explain_pretty_print = on
#dynamic_library_path = '$libdir'


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

autovacuum = on			        
#autovacuum_naptime = 60
autovacuum_vacuum_threshold = 600	# (executa o vacuum a cada grupo de 500 linhas atualizadas)
autovacuum_analyze_threshold = 300	# (executa o analyze a cada grupo de 300 linhas atualizadas)
autovacuum_vacuum_scale_factor = 0.4	# fraction of rel size before vacuum
autovacuum_analyze_scale_factor = 0.2	# fraction of rel size before analyze
autovacuum_vacuum_cost_delay = -1	# default vacuum cost delay for autovac, -1 means use vacuum_cost_delay
autovacuum_vacuum_cost_limit = -1	# default vacuum cost limit for autovac, -1 means use vacuum_cost_limit
