From: Shridhar Daithankar <shridhar_daithankar@persistent.co.in>
To: pgsql-patches@postgresql.org
To: pgsql-performance@postgresql.org
Subject: Another POC initdb patch
Date: Sun, 6 Jul 2003 19:40:32 +0530
Message-ID: <200307061940.32831.shridhar_daithankar@nospam.persistent.co.in> (raw)
Hi all,
In addition to Tom's patch, this patch asks tuning parameters right away,
while doing initdb. I have also changed the notice displayed after initdb is
done.
Just an attempt to make defaults user friendly. I would also like to add other
paramters to this approach, like fsync and random_page_cost but first I
thought others should have look at these.
And one more thing, can we get all the parameters in postgresql.conf to follow
similar units? Some settings aer in 8KB pages, some in bytes etc. Can we haev
all of them to follow say MB or KB?
I tried but guc.h and guc.c were bit too much to be gulped at one go. I will
try again.
Shridhar
Attachments:download all (2 files, .tar.gz)postgresql.conf.sample.patch (text/x-diff, 1.1K) download
*** postgresql.conf.sample.orig Sun Jul 6 15:51:02 2003
--- postgresql.conf.sample Sun Jul 6 17:17:23 2003
***************
*** 57,63 ****
# ---------------------------------
# Memory
! #shared_buffers = 64 # min 16, at least max_connections*2, 8KB each
#sort_mem = 1024 # min 64, size in KB
#vacuum_mem = 8192 # min 1024, size in KB
--- 57,64 ----
# ---------------------------------
# Memory
! # min 16, at least max_connections*2, 8KB each
! #shared_buffers
#sort_mem = 1024 # min 64, size in KB
#vacuum_mem = 8192 # min 1024, size in KB
***************
*** 105,111 ****
# Planner Cost Constants
! #effective_cache_size = 1000 # typically 8KB each
#random_page_cost = 4 # units are one sequential page fetch cost
#cpu_tuple_cost = 0.01 # (same)
#cpu_index_tuple_cost = 0.001 # (same)
--- 106,113 ----
# Planner Cost Constants
! # typically 8KB each
! #effective_cache_size
#random_page_cost = 4 # units are one sequential page fetch cost
#cpu_tuple_cost = 0.01 # (same)
#cpu_index_tuple_cost = 0.001 # (same)
initdb.patch (text/x-diff, 4.4K) download
*** initdb.orig Sun Jul 6 15:51:22 2003
--- initdb Sun Jul 6 19:34:24 2003
***************
*** 71,76 ****
--- 71,133 ----
echo "$ret"
}
+ #Set the values to default+ new_shared_buffers=" 64"+ new_effective_cache=" 1000"+ + #Get some good enough values for configuration+ pg_getDefault_Config(){+ echo+ echo+ echo " Now I am going to ask you some question regarding your system. "+ echo " These will help you in getting decent startup performance. "+ echo " The answers you provide here would be reflected in generated "+ echo " postgresql config file."+ echo+ read -p " Press any key to continue. " wvar+ + echo+ echo "Setting parameter: shared_buffers"+ echo " Unit: 8KB"+ echo " Type: Integer"+ echo+ echo " This parameter sets how much shared memory postgresql will use."+ echo " Value of this parameter depends upon size of dataset handled at"+ echo " a time and available memory."+ echo+ echo " This parameter is limited by maximum shared memory setting of the"+ echo " system. You might need to tune your kernel for your requirement."+ echo " Please refer to Administrator's guide for more details."+ echo+ echo " WARNING: Setting this parameter too high can cause loss of performance"+ echo " or postgresql might not start at all. Please adhere to guideline shown "+ echo " and apply your own judgement."+ echo+ echo " Description Memory Value"+ echo " Workstation or test database 4MB 512 "+ echo " Medium size database and 256-512 MB RAM 16-32MB 2048-4096"+ echo " Large database and >1GB memory 64-256MB 8192-32768"+ echo+ read -p "Enter value of shared_buffers: " new_shared_buffers+ + echo+ echo "Setting paramter: effective_cache_size"+ echo " Unit: 8KB"+ echo " Type: Integer"+ echo+ + echo " Postgresql will perform better if it knows how much file cache OS has."+ echo " This parameters gives hint to postgresql about the amount of file"+ echo " system cache."+ echo+ echo " There is nothing high or low about this parameter. It should be set to"+ echo " the correct value. Only change required is to account for memory"+ echo " requirement of other applications running on same machie. Being bit"+ echo " conservative on this parameter is recommended."+ echo+ read -p "Enter value of effective_cache_size: " new_effective_cache+ + }
CMDNAME=`basename $0`
***************
*** 583,597 ****
$ECHO_N "creating configuration files... "$ECHO_C
cp "$PG_HBA_SAMPLE" "$PGDATA"/pg_hba.conf || exit_nicely
cp "$PG_IDENT_SAMPLE" "$PGDATA"/pg_ident.conf || exit_nicely
(
trigger="# These settings are initialized by initdb -- they may be changed"
! sed -n "1,/$trigger/p" "$POSTGRESQL_CONF_SAMPLE"
for cat in MESSAGES MONETARY NUMERIC TIME; do
! echo "LC_$cat = '`pg_getlocale $cat`'"
done
! sed -n "1,/$trigger/!p" "$POSTGRESQL_CONF_SAMPLE"
) > "$PGDATA"/postgresql.conf || exit_nicely
chmod 0600 "$PGDATA"/pg_hba.conf "$PGDATA"/pg_ident.conf \
--- 640,660 ----
$ECHO_N "creating configuration files... "$ECHO_C
+ #Get the database tuning options+ pg_getDefault_Config+
cp "$PG_HBA_SAMPLE" "$PGDATA"/pg_hba.conf || exit_nicely
cp "$PG_IDENT_SAMPLE" "$PGDATA"/pg_ident.conf || exit_nicely
(
trigger="# These settings are initialized by initdb -- they may be changed"
! lcvars=""
for cat in MESSAGES MONETARY NUMERIC TIME; do
! lcvars="$lcvars\nLC_$cat = '`pg_getlocale $cat`'";
done
!
! sed "s/#shared_buffers/shared_buffers = $new_shared_buffers/" "$POSTGRESQL_CONF_SAMPLE"| \
! sed "s/#effective_cache_size/effective_cache_size = $new_effective_cache/" | \
! sed "s/$trigger/$trigger$lcvars/"
) > "$PGDATA"/postgresql.conf || exit_nicely
chmod 0600 "$PGDATA"/pg_hba.conf "$PGDATA"/pg_ident.conf \
***************
*** 1096,1102 ****
# FINISHED
echo
! echo "Success. You can now start the database server using:"
echo ""
echo " $PGPATH/postmaster -D $PGDATA"
echo "or"
--- 1159,1170 ----
# FINISHED
echo
! echo "Success."
! echo
! echo "Now you should tune the postgresql configuration file, $PGDATA/postgresql.conf"
! echo "Refer to Administrators guide for any further assistance for tuning options."
! echo
! echo "After you are done with tuning the options, you can start the postgresql server using"
echo ""
echo " $PGPATH/postmaster -D $PGDATA"
echo "or"
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: shridhar_daithankar@persistent.co.in, pgsql-patches@postgresql.org
Subject: Re: Another POC initdb patch
In-Reply-To: <200307061940.32831.shridhar_daithankar@nospam.persistent.co.in>
References: <200307061940.32831.shridhar_daithankar@nospam.persistent.co.in>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox