Re: Question: Is it possible to get the new xlog position after query execution?

2021-10-31 Thread Peter J. Holzer
On 2021-10-29 13:22:56 -0400, Oleg Serov wrote:
> We are using a master/slave replication system where we perform writes on
> master and use replication to offload reads.
> 
> However, sometimes we have a replication lag of a few seconds and as a result,
> after the update, the change is not yet available on the replica. 
> 
> Is there a way to get XLOG position to which specific update query will be
> written? That way we can check if our replica caught up with changes and it is
> safe to read it from. Can it be done using SQL functions? Can I get that
> information from query protocol?

I think I would prefer a more direct approach:

If you know what you've written, can't you just check whether the
replica has the new value(s)?

If not, an alternative could be a table which contains a simple counter
or timestamp:

begin;
(lots of updates ...)
commit;
begin;
update counter set c = c + 1 returning c; -- save this as c_current
commit;

Select c from counter on the replica in a loop until c >= c_current.

hp

-- 
   _  | Peter J. Holzer| Story must make more sense than reality.
|_|_) ||
| |   | h...@hjp.at |-- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |   challenge!"


signature.asc
Description: PGP signature


Re: Settings for a new machine - some guidance sought.

2021-10-31 Thread Laurenz Albe
On Sat, 2021-10-30 at 16:31 +, SQL Padawan wrote:
> I would be grateful if anyone could comment on the suitability or otherwise 
> of any/some/all of these settings.
> 
> Good references/URLs/.pdfs/texts much appreciated.
> 
> Please let me know if you require any more information.

Without knowing details of the workload, the number of concurrent queries etc.
you can only guess, like pgtune does.

Yours,
Laurenz Albe