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.
You must add the line shown below in your lightdb.conf
.
shared_preload_libraries = 'lt_standby_forward'
lt_standby_forward uses 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 lt_hba.conf
on primary, or put password in passfile
on standby to avoid typing password.
Forwards DELETE, UPDATE, INSERT, SELECT with modifying CTE to primary.
Forwards SELECT/CALL statements containing volatile function to primary, otherwise executes on standby.
Executes read only transactions on standby, otherwise forwards 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.
Executes 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 forwarded to primary.