F.22. lt_standby_forward

F.22.1. Configuration Parameters
F.22.2. Usage
F.22.3. Authentication
F.22.4. Features/Limitations

lt_standby_forward is a module which forwards SQL statements from a hot standby to primary, providing a facility to reduce loading of primary, and to allow clients query from standby. For example, clients can send INSERT, CREATE to a hot standby.

F.22.1. Configuration Parameters

lt_standby_forward.enable_forward

It controls whether this feature is enabled or not user. Default is off. Set this option on standby, or for a single session.

F.22.2. Usage

You must add the line shown below in your postgresql.conf.

shared_preload_libraries = 'lt_standby_forward'

F.22.3. Authentication

lt_standby_forward use primary_conninfo to connect to primary, appending current dbname and username (i.e. the db and user used to connect to standby) to primary_conninfo. The connection info looks like

primary_conninfo dbname=a_db user=a_user application_name=lt_standby_forward options='-c opt1=value1 -c opt2=value2'

It is not supported to set passward. Config pg_hba.conf on primary, or put password in passfile on standby to avoid typing password.

F.22.4. Features/Limitations

  • Forward DELETE, UPDATE, INSERT, SELECT with modifying CTE to primary.

  • Forward SELECT/CALL statements containing volatile function to primary, otherwise execute on standby.

  • Execute read only transactions on standby, otherwise forward to primary.

  • DDL is not allowed in transactions.

  • View is rewriten (expanded) on standby before forwarding to primary. Query fails if view contains objects cannot be accessed by current user.

  • Execute SET on both sides, execute show on standby. Don't SET xxx_timeout after connection established, set these parameters with ltsql/jdbc parameter options. For ltsql/jdbc options, only statement_timeout, lock_timeout and idle_in_transaction_session_timeout will be pass to primary.

  • COPY FROM is not supported.

  • CREATE TEMP/UNLOGGED TABLE is not supported.

  • Utility commands not mentioned above are forward to primary.