Re: xlog location arithmetic - Mailing list pgsql-hackers

From Euler Taveira de Oliveira
Subject Re: xlog location arithmetic
Date
Msg-id 4EDE5349.3070009@timbira.com
Whole thread Raw
In response to Re: xlog location arithmetic  (Magnus Hagander <magnus@hagander.net>)
List pgsql-hackers
On 06-12-2011 07:14, Magnus Hagander wrote:
> On Tue, Dec 6, 2011 at 05:19, Euler Taveira de Oliveira
> <euler@timbira.com> wrote:
>> Hi,
>>
>> A while ago when blogging about WAL [1], I noticed a function to deal with
>> xlog location arithmetic is wanted. I remembered Depez [2] mentioning it and
>> after some questions during trainings and conferences I decided to translate
>> my shell script function in C.
>>
>> The attached patch implements the function pg_xlog_location_diff (bikeshed
>> colors are welcome). It calculates the difference between two given
>> transaction log locations. Now that we have pg_stat_replication view, it will
>> be easy to get the lag just passing columns as parameters. Also, the
>> monitoring tools could take advantage of it instead of relying on a fragile
>> routine to get the lag.
> 
> I've been considering similar things, as you can find in the archives,
> but what I was thinking of was converting the number to just a plain
> bigint, then letting the user apply whatever arithmetic wanted at the
> SQL level. I never got around to acutally coding it, though. It could
> easily be extracted from your patch of course - and I think that's a
> more flexible approach. Is there some advantage to your method that
> I'm missing?
> 
The only advantage is that you don't expose the arithmetic, e.g., user doesn't
need to know the xlog internals (like I described in a recent blog post). If
one day we consider changes in xlog arithmetic (for example, XLogFileSize), we
don't need to worry too much about external tools.

> Also, why do you use DirectFunctionCall to do the simple math, and not
> just do the math right there in the function?
> 
I use it because I don't want to duplicate the overflow code.


--   Euler Taveira de Oliveira - Timbira       http://www.timbira.com.br/  PostgreSQL: Consultoria, Desenvolvimento,
Suporte24x7 e Treinamento
 


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Inlining comparators as a performance optimisation
Next
From: Robert Haas
Date:
Subject: Re: Inlining comparators as a performance optimisation