Обсуждение: Checkpoint versus Background Writer

Поиск
Список
Период
Сортировка

Checkpoint versus Background Writer

От
Shiv Sharma
Дата:
They seem to do similar things: clear dirty buffers from shared_buffers to disk.

So why have 2 processes with seperate semantics (seperate set of config partms) ?

Assuming PG is multi-threaded, can't we simply have multiple threads of the checkpoint achieve the same result as (checkpoint + bg)


Shiv

Re: Checkpoint versus Background Writer

От
"SUNDAY A. OLUTAYO"
Дата:
Checkpoint is different to background writer though works together
BGW continuously write buffer to disk but checkpoint is interval default to 5min at which the process call BGW to flush the entire buffer to disk

Thanks,

Sunday Olutayo



From: "Shiv Sharma" <shiv.sharma.1835@gmail.com>
To: pgsql-novice@postgresql.org
Sent: Friday, December 27, 2013 8:46:42 PM
Subject: [NOVICE] Checkpoint versus Background Writer

They seem to do similar things: clear dirty buffers from shared_buffers to disk.

So why have 2 processes with seperate semantics (seperate set of config partms) ?

Assuming PG is multi-threaded, can't we simply have multiple threads of the checkpoint achieve the same result as (checkpoint + bg)


Shiv

Re: Checkpoint versus Background Writer

От
Shiv Sharma
Дата:
>Checkpoint is different to background writer though works together
>BGW continuously write buffer to disk but checkpoint is interval default to 5min at which the process call >BGW to flush the entire buffer to disk

But with 8.3 and checkpoint_completion_target, is not the checkpoint spread out too? (or can be spread out).



On Fri, Dec 27, 2013 at 10:58 AM, SUNDAY A. OLUTAYO <olutayo@sadeeb.com> wrote:
Checkpoint is different to background writer though works together
BGW continuously write buffer to disk but checkpoint is interval default to 5min at which the process call BGW to flush the entire buffer to disk

Thanks,

Sunday Olutayo



From: "Shiv Sharma" <shiv.sharma.1835@gmail.com>
To: pgsql-novice@postgresql.org
Sent: Friday, December 27, 2013 8:46:42 PM
Subject: [NOVICE] Checkpoint versus Background Writer


They seem to do similar things: clear dirty buffers from shared_buffers to disk.

So why have 2 processes with seperate semantics (seperate set of config partms) ?

Assuming PG is multi-threaded, can't we simply have multiple threads of the checkpoint achieve the same result as (checkpoint + bg)


Shiv


Re: Checkpoint versus Background Writer

От
"SUNDAY A. OLUTAYO"
Дата:
I do not understand your statement

Thanks,

Sunday Olutayo


From: "Shiv Sharma" <shiv.sharma.1835@gmail.com>
To: "SUNDAY A. OLUTAYO" <olutayo@sadeeb.com>
Cc: pgsql-novice@postgresql.org
Sent: Friday, December 27, 2013 9:41:58 PM
Subject: Re: [NOVICE] Checkpoint versus Background Writer

>Checkpoint is different to background writer though works together
>BGW continuously write buffer to disk but checkpoint is interval default to 5min at which the process call >BGW to flush the entire buffer to disk

But with 8.3 and checkpoint_completion_target, is not the checkpoint spread out too? (or can be spread out).



On Fri, Dec 27, 2013 at 10:58 AM, SUNDAY A. OLUTAYO <olutayo@sadeeb.com> wrote:
Checkpoint is different to background writer though works together
BGW continuously write buffer to disk but checkpoint is interval default to 5min at which the process call BGW to flush the entire buffer to disk

Thanks,

Sunday Olutayo



From: "Shiv Sharma" <shiv.sharma.1835@gmail.com>
To: pgsql-novice@postgresql.org
Sent: Friday, December 27, 2013 8:46:42 PM
Subject: [NOVICE] Checkpoint versus Background Writer


They seem to do similar things: clear dirty buffers from shared_buffers to disk.

So why have 2 processes with seperate semantics (seperate set of config partms) ?

Assuming PG is multi-threaded, can't we simply have multiple threads of the checkpoint achieve the same result as (checkpoint + bg)


Shiv



Re: Checkpoint versus Background Writer

От
Sergey Konoplev
Дата:
On Fri, Dec 27, 2013 at 11:46 AM, Shiv Sharma
<shiv.sharma.1835@gmail.com> wrote:
> They seem to do similar things: clear dirty buffers from shared_buffers to
> disk.
>
> So why have 2 processes with seperate semantics (seperate set of config
> partms) ?

AFAIU, they serve for completely different purposes.

Background writer is for performance. Each round, based on shared
memory usage statistics and LRU data, it estimates how many new pages
user backend processes will require before the next round, and flushes
necessary amount of dirty pages on disk. So user backend processes
will have enough non-dirty pages to operate with, and wont need to
spend time on doing flushing themselves, that allows to return control
to users faster.

Checkpoints is a part of reliability mechanism. It applies changes
accumulated in WAL files, that have not been applied earlier by
background writer or user backends, to data files, keeping the
database consistent before performing rotation.

Correct me if I missed or misunderstood something.

--
Kind regards,
Sergey Konoplev
PostgreSQL Consultant and DBA

http://www.linkedin.com/in/grayhemp
+1 (415) 867-9984, +7 (901) 903-0499, +7 (988) 888-1979
gray.ru@gmail.com


Re: Checkpoint versus Background Writer

От
Tom Lane
Дата:
Sergey Konoplev <gray.ru@gmail.com> writes:
> On Fri, Dec 27, 2013 at 11:46 AM, Shiv Sharma
> <shiv.sharma.1835@gmail.com> wrote:
>> They seem to do similar things: clear dirty buffers from shared_buffers to
>> disk.
>>
>> So why have 2 processes with seperate semantics (seperate set of config
>> partms) ?

> AFAIU, they serve for completely different purposes.

We used to have a single process trying to serve both purposes, but
it didn't work tremendously well, because the criteria for when to
flush buffers are so different.

            regards, tom lane