Em 19 de janeiro de 2012 17:38, Flavio Henrique Araque Gurgel < fha...@gmail.com> escreveu:
> > Sobre transações, vide as funções em [2]. > > > > [1] > http://eulerto.blogspot.com/2011/11/understanding-wal-nomenclature.html > > [2] > > > http://www.postgresql.org/docs/current/static/functions-info.html#FUNCTIONS-TXID-SNAPSHOT > > Obrigado Euler. > E se precisar calcular a diferença em bytes do xlog da replica e do master (lag), pode usar as funções: -- Convert from HEX to INT CREATE OR REPLACE FUNCTION hex2int(TEXT) RETURNS bigint AS $$ DECLARE result BIGINT; BEGIN EXECUTE 'SELECT CAST(X'||quote_literal($1)||' AS BIGINT)' INTO result; RETURN result; END; $$ LANGUAGE plpgsql; -- -- Parameters: 1 = xlog master -- 2 = xlog replica -- CREATE OR REPLACE FUNCTION pg_replication_lag_bytes(TEXT, TEXT) RETURNS bigint AS $$ SELECT ( hex2int('FF000000') * hex2int( split_part($1, '/', 1) ) + hex2int( split_part($1, '/', 2) ) ) - ( hex2int('FF000000') * hex2int( split_part($2, '/', 1) ) + hex2int( split_part($2, '/', 2) ) ); $$ LANGUAGE sql; postgres@bdteste=# SELECT pg_replication_lag_bytes('67E/AFE198', '67D/FECFA308'); pg_replication_lag_bytes -------------------------- 14696080 (1 registro) -- Fabrízio de Royes Mello Consultoria/Coaching PostgreSQL >> Blog sobre TI: http://fabriziomello.blogspot.com >> Perfil Linkedin: http://br.linkedin.com/in/fabriziomello >> Twitter: http://twitter.com/fabriziomello
_______________________________________________ pgbr-geral mailing list pgbr-geral@listas.postgresql.org.br https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral