Thread: random write in xlog?

random write in xlog?

From
flyusa2010 fly
Date:
Hi, folks,

I trace the running postgres, and I found that there are some randoms writes in xlog files!
To my impression, log file writing is always sequential, how come random writes happen? 

Thanks in advance!

Re: random write in xlog?

From
Jeff Janes
Date:
On Tue, Dec 7, 2010 at 2:06 PM, flyusa2010 fly <flyusa2010@gmail.com> wrote:
> Hi, folks,
> I trace the running postgres, and I found that there are some randoms writes
> in xlog files!
> To my impression, log file writing is always sequential, how come random
> writes happen?
> Thanks in advance!

Just because it does an lseek doesn't mean it is "random".

Anyway, the writes are logically sequentially, but not physically.  If
I remember correctly, it always writes out full blocks, even if the
last part of the block has not yet been filled with new data.  When
the remainder gets filled, it then writes out the full block again,
both the already written and the new part.

Cheers,

Jeff


XLog vs SSD [Was: Re: random write in xlog?]

From
James Cloos
Date:
>>>>> "JJ" == Jeff Janes <jeff.janes@gmail.com> writes:

JJ> Anyway, the writes are logically sequentially, but not physically.
JJ> If I remember correctly, it always writes out full blocks, even if
JJ> the last part of the block has not yet been filled with new data.
JJ> When the remainder gets filled, it then writes out the full block
JJ> again, both the already written and the new part.

What does that mean for use of a flash SSD for the xlog dir?

Does the block writing mesh up well with the usage pattern a flash
SSD needs to maximize lifespan?

I'd love a dram ssd for pg_xlog and the journals for the other
filesystems, but they cost too much.

-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 1024D/ED7DAEA6


Re: XLog vs SSD [Was: Re: random write in xlog?]

From
Jeff Janes
Date:
On Wed, Dec 8, 2010 at 12:15 PM, James Cloos <cloos@jhcloos.com> wrote:
>>>>>> "JJ" == Jeff Janes <jeff.janes@gmail.com> writes:
>
> JJ> Anyway, the writes are logically sequentially, but not physically.
> JJ> If I remember correctly, it always writes out full blocks, even if
> JJ> the last part of the block has not yet been filled with new data.
> JJ> When the remainder gets filled, it then writes out the full block
> JJ> again, both the already written and the new part.
>
> What does that mean for use of a flash SSD for the xlog dir?
>
> Does the block writing mesh up well with the usage pattern a flash
> SSD needs to maximize lifespan?

I think that SSD have a block size below which writing only part of
the block has the same effect as writing the whole thing.  And those
block sizes are larger than 8K.
So PG always writing 8K at a time is unlikely to make a difference
than if it wrote a smaller amount.

Cheers,

Jeff


Re: XLog vs SSD [Was: Re: random write in xlog?]

From
James Cloos
Date:
>>>>> "JJ" == Jeff Janes <jeff.janes@gmail.com> writes:

JJ> So PG always writing 8K at a time is unlikely to make a difference
JJ> than if it wrote a smaller amount.

Ah.

Somehow I was thinking of the xlog files' 16M filesize rather than the
internal 8k block size....

If it is only writing 8k blocks then there is probably little hope of
making efficient use of flash.

-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 1024D/ED7DAEA6