*** 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"
