Re: [HACKERS] Visibility map page pinned for too long ?

2012-12-03 Thread Simon Riggs
On 3 December 2012 17:37, Pavan Deolasee wrote: > I was looking at the code when the following tiny bit caught my attention. > In vacuumlazy.c, we release the pin on the final VM page at line number 972. > > 954 if (vacrelstats->num_dead_tuples > 0) > 955 { > 956 /* Log cleanup

[HACKERS] Visibility map page pinned for too long ?

2012-12-03 Thread Pavan Deolasee
I was looking at the code when the following tiny bit caught my attention. In vacuumlazy.c, we release the pin on the final VM page at line number 972. 954 if (vacrelstats->num_dead_tuples > 0) 955 { 956 /* Log cleanup info before we touch indexes */ 957 vacuum_log_clea

Re: [HACKERS] Visibility map and hint bits

2011-05-06 Thread Merlin Moncure
On Thu, May 5, 2011 at 2:20 PM, Merlin Moncure wrote: > On Thu, May 5, 2011 at 2:00 PM, Kevin Grittner > wrote: >> Merlin Moncure wrote: >> >>> a small cache that remembers the commit/cancel status of recently >>> seen transactions. >> >> How is that different from the head of the clog SLRU? > >

Re: [HACKERS] Visibility map and hint bits

2011-05-05 Thread Merlin Moncure
On Thu, May 5, 2011 at 2:00 PM, Kevin Grittner wrote: > Merlin Moncure wrote: > >> a small cache that remembers the commit/cancel status of recently >> seen transactions. > > How is that different from the head of the clog SLRU? several things: *) any slru access requires lock (besides the lock

Re: [HACKERS] Visibility map and hint bits

2011-05-05 Thread Kevin Grittner
Merlin Moncure wrote: > a small cache that remembers the commit/cancel status of recently > seen transactions. How is that different from the head of the clog SLRU? -Kevin -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www

Re: [HACKERS] Visibility map and hint bits

2011-05-05 Thread Merlin Moncure
On Thu, May 5, 2011 at 1:34 PM, Bruce Momjian wrote: > Merlin Moncure wrote: >> On Thu, May 5, 2011 at 11:59 AM, Bruce Momjian wrote: >> > There has been a lot of recent discussion about the visibility map (for >> > index-only scans) and hint bits (trying to avoid double-writing a >> > table). >>

Re: [HACKERS] Visibility map and hint bits

2011-05-05 Thread Robert Haas
On Thu, May 5, 2011 at 12:59 PM, Bruce Momjian wrote: > I wonder if we could fix both of these at the same time.  Once the > visibility map is reliable, can we use that to avoid updating the hint > bits on all rows on a page? I don't think so. There are two problems: 1. If there is a long-runni

Re: [HACKERS] Visibility map and hint bits

2011-05-05 Thread Bruce Momjian
Merlin Moncure wrote: > On Thu, May 5, 2011 at 11:59 AM, Bruce Momjian wrote: > > There has been a lot of recent discussion about the visibility map (for > > index-only scans) and hint bits (trying to avoid double-writing a > > table). > > I still think a small tqual.c maintained cache of hint bi

Re: [HACKERS] Visibility map and hint bits

2011-05-05 Thread Merlin Moncure
On Thu, May 5, 2011 at 11:59 AM, Bruce Momjian wrote: > There has been a lot of recent discussion about the visibility map (for > index-only scans) and hint bits (trying to avoid double-writing a > table). I still think a small tqual.c maintained cache of hint bits will effectively eliminate hint

[HACKERS] Visibility map and hint bits

2011-05-05 Thread Bruce Momjian
There has been a lot of recent discussion about the visibility map (for index-only scans) and hint bits (trying to avoid double-writing a table). I wonder if we could fix both of these at the same time. Once the visibility map is reliable, can we use that to avoid updating the hint bits on all ro

Re: [HACKERS] visibility map

2010-11-23 Thread Robert Haas
On Tue, Nov 23, 2010 at 3:42 AM, Heikki Linnakangas wrote: > That's an interesting idea. You pickyback setting the vm bit on the freeze > WAL record, on the assumption that you have to write the freeze record > anyway. However, if that assumption doesn't hold, because the tuples are > deleted befo

Re: [HACKERS] visibility map

2010-11-23 Thread Heikki Linnakangas
On 22.11.2010 21:24, Robert Haas wrote: Eh, so. Suppose - for the sake of argument - we do the following: 1. Allocate an additional infomask(2) bit that means "xmin is frozen, no need to call XidInMVCCSnapshot()". When we freeze a tuple, we set this bit in lieu of overwriting xmin. Note that

Re: [HACKERS] visibility map

2010-11-23 Thread 高增琦
Can we just log the change of VM in log_heap_clean() for redo? Thanks -- GaoZengqi pgf...@gmail.com zengqi...@gmail.com On Tue, Nov 23, 2010 at 3:24 AM, Robert Haas wrote: > On Mon, Jun 14, 2010 at 1:19 AM, Heikki Linnakangas > wrote: > >> I *think* that the answer to this parenthesized quest

Re: [HACKERS] visibility map

2010-11-22 Thread Robert Haas
On Mon, Jun 14, 2010 at 1:19 AM, Heikki Linnakangas wrote: >> I *think* that the answer to this parenthesized question is "no". >> When we vacuum a page, we set the LSN on both the heap page and the >> visibility map page.  Therefore, neither of them can get written to >> disk until the WAL record

Re: [HACKERS] visibility map

2010-06-13 Thread Heikki Linnakangas
On 14/06/10 06:08, Robert Haas wrote: visibilitymap.c begins with a long and useful comment - but this part seems to have a bit of split personality disorder. * Currently, the visibility map is not 100% correct all the time. * During updates, the bit in the visibility map is cleared after re

[HACKERS] visibility map

2010-06-13 Thread Robert Haas
visibilitymap.c begins with a long and useful comment - but this part seems to have a bit of split personality disorder. * Currently, the visibility map is not 100% correct all the time. * During updates, the bit in the visibility map is cleared after releasing * the lock on the heap page. Duri

Re: [HACKERS] Visibility map and freezing

2009-01-22 Thread Heikki Linnakangas
Euler Taveira de Oliveira wrote: Simon Riggs escreveu: On Tue, 2009-01-20 at 21:51 +0200, Heikki Linnakangas wrote: Attached is a simple patch to only start skipping pages after 20 consecutive pages marked as visible in the visibility map. This doesn't do any "look-ahead", so it will always s

Re: [HACKERS] Visibility map and freezing

2009-01-22 Thread Heikki Linnakangas
Heikki Linnakangas wrote: ITAGAKI Takahiro wrote: - What relation are there between autovacuum_freeze_max_age, vacuum_freeze_min_age and vacuum_freeze_table_age? If we increase one of them, should we also increase the others? Yeah, that's a fair question. I'll try to work a doc patch to ex

Re: [HACKERS] Visibility map and freezing

2009-01-20 Thread Euler Taveira de Oliveira
Simon Riggs escreveu: > On Tue, 2009-01-20 at 21:51 +0200, Heikki Linnakangas wrote: > >> Attached is a simple patch to only start skipping pages after 20 >> consecutive pages marked as visible in the visibility map. This doesn't >> do any "look-ahead", so it will always scan the first 20 pages

Re: [HACKERS] Visibility map and freezing

2009-01-20 Thread Simon Riggs
On Tue, 2009-01-20 at 21:51 +0200, Heikki Linnakangas wrote: > Attached is a simple patch to only start skipping pages after 20 > consecutive pages marked as visible in the visibility map. This doesn't > do any "look-ahead", so it will always scan the first 20 pages of a > table before it star

Re: [HACKERS] Visibility map and freezing

2009-01-20 Thread Heikki Linnakangas
Simon Riggs wrote: On Tue, 2009-01-20 at 11:03 +0200, Heikki Linnakangas wrote: - Are there some conditions where whole-table-scanning vacuum is more effective than vacuums using visibility map? If so, we should switch to full-scan *automatically*, without relying on user configurations

Re: [HACKERS] Visibility map and freezing

2009-01-20 Thread Simon Riggs
On Tue, 2009-01-20 at 11:03 +0200, Heikki Linnakangas wrote: > > - Are there some conditions where whole-table-scanning vacuum is > more > > effective than vacuums using visibility map? If so, we should > switch > > to full-scan *automatically*, without relying on user > configurations. > > H

Re: [HACKERS] Visibility map and freezing

2009-01-20 Thread Heikki Linnakangas
ITAGAKI Takahiro wrote: Gregory Stark wrote: I don't think we can perfectly capture the meaning of these GUCs in the name. I think our goal should be to avoid confusion between them. I was thinking it would be clearer if the options which control *when* autovacuum fires off a worker consisten

Re: [HACKERS] Visibility map and freezing

2009-01-18 Thread ITAGAKI Takahiro
Gregory Stark wrote: > >> I don't think we can perfectly capture the meaning of these GUCs in the > >> name. I think our goal should be to avoid confusion between them. > > I was thinking it would be clearer if the options which control *when* > autovacuum fires off a worker consistently had so

Re: [HACKERS] Visibility map and freezing

2009-01-16 Thread Heikki Linnakangas
Alvaro Herrera wrote: Heikki Linnakangas escribió: This patch adds a new column to pg_autovacuum, reflecting the new vacuum_freeze_table_age GUC just like freeze_min_age column reflects vacuum_freeze_min_age. If I commit this tomorrow, will I cause you a lot of trouble with the reloptions patc

Re: [HACKERS] Visibility map and freezing

2009-01-16 Thread Gregory Stark
Heikki Linnakangas writes: > Jeff Davis wrote: >> On Fri, 2009-01-09 at 13:49 +0200, Heikki Linnakangas wrote: >>> >>> I'm now leaning towards: >>> >>> autovacuum_freeze_max_age >>> vacuum_freeze_table_age >>> vacuum_freeze_min_age >>> >>> where autovacuum_freeze_max_age and vacuum_freeze_min_age

Re: [HACKERS] Visibility map and freezing

2009-01-15 Thread Alvaro Herrera
Heikki Linnakangas escribió: > Alvaro, are you getting rid of pg_autovacuum in favor of the reloptions > for 8.4? That's the intention, yes. > This patch adds a new column to pg_autovacuum, reflecting the new > vacuum_freeze_table_age GUC just like freeze_min_age column reflects > vacuum_free

Re: [HACKERS] Visibility map and freezing

2009-01-15 Thread Heikki Linnakangas
Jeff Davis wrote: On Fri, 2009-01-09 at 13:49 +0200, Heikki Linnakangas wrote: If the distinction you're making is that autovacuum_freeze_max_age affects the launching of a vacuum rather than the behavior of a vacuum, maybe we could incorporate the word "launch" like: autovacuum_launch_freeze_th

Re: [HACKERS] Visibility map, partial vacuums

2009-01-15 Thread Heikki Linnakangas
Bruce Momjian wrote: Heikki Linnakangas wrote: Also, is anything being done about the concern about 'vacuum storm' explained below? I'm interested too. The additional "vacuum_freeze_table_age" (as I'm now calling it) setting I discussed in a later thread should alleviate that somewhat. When a

Re: [HACKERS] Visibility map, partial vacuums

2009-01-15 Thread Bruce Momjian
Gregory Stark wrote: > Bruce Momjian writes: > > > Would someone tell me why 'autovacuum_freeze_max_age' defaults to 200M > > when our wraparound limit is around 2B? > > I suggested raising it dramatically in the post you quote and Heikki pointed > it controls the maximum amount of space the clo

Re: [HACKERS] Visibility map, partial vacuums

2009-01-15 Thread Bruce Momjian
Heikki Linnakangas wrote: > >> Also, is anything being done about the concern about 'vacuum storm' > >> explained below? > > > > I'm interested too. > > The additional "vacuum_freeze_table_age" (as I'm now calling it) setting > I discussed in a later thread should alleviate that somewhat. When a

Re: [HACKERS] Visibility map, partial vacuums

2009-01-14 Thread Heikki Linnakangas
Gregory Stark wrote: Bruce Momjian writes: Would someone tell me why 'autovacuum_freeze_max_age' defaults to 200M when our wraparound limit is around 2B? I suggested raising it dramatically in the post you quote and Heikki pointed it controls the maximum amount of space the clog will take. R

Re: [HACKERS] Visibility map, partial vacuums

2009-01-14 Thread Gregory Stark
Bruce Momjian writes: > Would someone tell me why 'autovacuum_freeze_max_age' defaults to 200M > when our wraparound limit is around 2B? I suggested raising it dramatically in the post you quote and Heikki pointed it controls the maximum amount of space the clog will take. Raising it to, say, 80

Re: [HACKERS] Visibility map, partial vacuums

2009-01-14 Thread Bruce Momjian
Andrew Dunstan wrote: > > > Bruce Momjian wrote: > > Would someone tell me why 'autovacuum_freeze_max_age' defaults to 200M > > when our wraparound limit is around 2B? > > > > Presumably because of this (from the docs): > > "The commit status uses two bits per transaction, so if > autovacuu

Re: [HACKERS] Visibility map, partial vacuums

2009-01-14 Thread Andrew Dunstan
Bruce Momjian wrote: Would someone tell me why 'autovacuum_freeze_max_age' defaults to 200M when our wraparound limit is around 2B? Presumably because of this (from the docs): "The commit status uses two bits per transaction, so if autovacuum_freeze_max_age has its maximum allowed value

Re: [HACKERS] Visibility map, partial vacuums

2009-01-14 Thread Bruce Momjian
Would someone tell me why 'autovacuum_freeze_max_age' defaults to 200M when our wraparound limit is around 2B? Also, is anything being done about the concern about 'vacuum storm' explained below? --- Gregory Stark wrote: >

Re: [HACKERS] Visibility map and freezing

2009-01-09 Thread Jeff Davis
On Fri, 2009-01-09 at 13:49 +0200, Heikki Linnakangas wrote: > Thinking about this some more, I'm not too happy with those names > either. vacuum_freeze_scan_age and autovacuum_freeze_scan_age don't mean > quite the same thing, like vacuum_cost_delay and > autovacuum_vacuum_cost_delay do, for ex

Re: [HACKERS] Visibility map and freezing

2009-01-09 Thread Heikki Linnakangas
Jeff Davis wrote: On Wed, 2009-01-07 at 09:34 +0200, Heikki Linnakangas wrote: autovacuum_freeze_max_age -> autovacuum_freeze_scan_age vacuum_freeze_max_age -> vacuum_freeze_scan_age vacuum_freeze_min_age -> vacuum_freeze_tuple_age *_scan_age settings control when the table is fully scanned

Re: [HACKERS] Visibility map and freezing

2009-01-07 Thread Jeff Davis
On Wed, 2009-01-07 at 09:34 +0200, Heikki Linnakangas wrote: > autovacuum_freeze_max_age -> autovacuum_freeze_scan_age > vacuum_freeze_max_age -> vacuum_freeze_scan_age > vacuum_freeze_min_age -> vacuum_freeze_tuple_age > > *_scan_age settings control when the table is fully scanned to freeze > t

Re: [HACKERS] Visibility map and freezing

2009-01-06 Thread Heikki Linnakangas
Jeff Davis wrote: On Mon, 2008-12-22 at 21:24 +0200, Heikki Linnakangas wrote: Introduce new vacuum_freeze_max_age setting. Manual VACUUM will scan the whole table and advance relfrozenxid, if relfrozenxid is older than vacuum_freeze_max_age. It's confusing to have two GUCs named vacuum_fre

Re: [HACKERS] Visibility map and freezing

2008-12-23 Thread Jeff Davis
On Mon, 2008-12-22 at 21:24 +0200, Heikki Linnakangas wrote: > Introduce new vacuum_freeze_max_age setting. Manual VACUUM will scan the > whole table and advance relfrozenxid, if relfrozenxid is older than > vacuum_freeze_max_age. > It's confusing to have two GUCs named vacuum_freeze_min_age an

Re: [HACKERS] Visibility map and freezing

2008-12-22 Thread Fujii Masao
On Tue, Dec 23, 2008 at 4:24 AM, Heikki Linnakangas wrote: > Heikki Linnakangas wrote: >> >> Peter Eisentraut wrote: >>> >>> Heikki Linnakangas wrote: I think we need a threshold similar to autovacuum_freeze_max_age for manual vacuums as well: vacuum_freeze_max_age. If you run VACUU

Re: [HACKERS] Visibility map and freezing

2008-12-22 Thread Heikki Linnakangas
Heikki Linnakangas wrote: Peter Eisentraut wrote: Heikki Linnakangas wrote: I think we need a threshold similar to autovacuum_freeze_max_age for manual vacuums as well: vacuum_freeze_max_age. If you run VACUUM, and relfrozenxid is older than vacuum_freeze_max_age, the visibility map is ignore

Re: [HACKERS] Visibility map and freezing

2008-12-18 Thread Heikki Linnakangas
Peter Eisentraut wrote: Heikki Linnakangas wrote: I think we need a threshold similar to autovacuum_freeze_max_age for manual vacuums as well: vacuum_freeze_max_age. If you run VACUUM, and relfrozenxid is older than vacuum_freeze_max_age, the visibility map is ignored and all pages are scanned

Re: [HACKERS] Visibility map and freezing

2008-12-18 Thread Peter Eisentraut
Heikki Linnakangas wrote: I think we need a threshold similar to autovacuum_freeze_max_age for manual vacuums as well: vacuum_freeze_max_age. If you run VACUUM, and relfrozenxid is older than vacuum_freeze_max_age, the visibility map is ignored and all pages are scanned. Would one parameter t

Re: [HACKERS] Visibility map and freezing

2008-12-17 Thread Gregory Stark
Zdenek Kotala writes: > What's about add second bit which mark frozen page (all tuples have freeze > XID)? It should avoid full scan, but extend size of map. That would only really work if you have a very static table where entire pages get frozen and stay frozen long before the freeze_max_age i

Re: [HACKERS] Visibility map and freezing

2008-12-17 Thread Heikki Linnakangas
Zdenek Kotala wrote: What's about add second bit which mark frozen page (all tuples have freeze XID)? It should avoid full scan, but extend size of map. First of all, we'd still have to make the decision of when to scan pages that need freezing, and when to only scan pages that have dead tuple

Re: [HACKERS] Visibility map and freezing

2008-12-17 Thread Zdenek Kotala
What's about add second bit which mark frozen page (all tuples have freeze XID)? It should avoid full scan, but extend size of map. Zdenek Heikki Linnakangas napsal(a): The way VACUUM works with the visibility map is that if any pages are skipped, relfrozenxid can't b

[HACKERS] Visibility map and freezing

2008-12-17 Thread Heikki Linnakangas
The way VACUUM works with the visibility map is that if any pages are skipped, relfrozenxid can't be updated. That means that plain VACUUM won't advance relfrozenxid, and doesn't protect from XID wraparound. We discussed this in the context of autovacuum before, and we have that covered now. A

Re: [HACKERS] visibility map and reltuples

2008-12-17 Thread Heikki Linnakangas
Tom Lane wrote: I think your previous sketch is right: suppress update of reltuples (and relpages) from a partial vacuum scan, and ensure that the analyze phase is allowed to do it instead if it happens during VACUUM ANALYZE. We also mustn't reset n_live_tuples in pgstat in partial vacuum. Com

Re: [HACKERS] visibility map and reltuples

2008-12-15 Thread Greg Smith
On Mon, 15 Dec 2008, Greg Stark wrote: I wonder if we should switch to keeping reltuplesperpage instead. It would be preferrable to not touch the user side of reltuples if possible, since it's the only instant way to get a good estimate of the number of rows in a table right now. That's bee

Re: [HACKERS] visibility map and reltuples

2008-12-15 Thread Tom Lane
Heikki Linnakangas writes: > Greg Stark wrote: >> I wonder if we should switch to keeping reltuplesperpage instead. Then a >> partial vacuum could update it by taking the average number of tuples >> per page forbthe pages it saw. Perhaps adjusting it to the weights >> average between the old va

Re: [HACKERS] visibility map and reltuples

2008-12-15 Thread Heikki Linnakangas
Greg Stark wrote: I wonder if we should switch to keeping reltuplesperpage instead. Then a partial vacuum could update it by taking the average number of tuples per page forbthe pages it saw. Perhaps adjusting it to the weights average between the old value and the new value based on how many p

Re: [HACKERS] visibility map and reltuples

2008-12-15 Thread Greg Stark
I wonder if we should switch to keeping reltuplesperpage instead. Then a partial vacuum could update it by taking the average number of tuples per page forbthe pages it saw. Perhaps adjusting it to the weights average between the old value and the new value based on how many pages were seen

Re: [HACKERS] visibility map and reltuples

2008-12-15 Thread Heikki Linnakangas
Heikki Linnakangas wrote: Ned T. Crigler wrote: It appears that the visibility map patch is causing pg_class.reltuples to be set improperly after a vacuum. For example, it is set to 0 if the map indicated that no pages in the heap needed to be scanned. Perhaps reltuples should not be updated u

Re: [HACKERS] visibility map and reltuples

2008-12-14 Thread Heikki Linnakangas
Ned T. Crigler wrote: It appears that the visibility map patch is causing pg_class.reltuples to be set improperly after a vacuum. For example, it is set to 0 if the map indicated that no pages in the heap needed to be scanned. Perhaps reltuples should not be updated unless every page was scanned

[HACKERS] visibility map and reltuples

2008-12-13 Thread Ned T. Crigler
It appears that the visibility map patch is causing pg_class.reltuples to be set improperly after a vacuum. For example, it is set to 0 if the map indicated that no pages in the heap needed to be scanned. Perhaps reltuples should not be updated unless every page was scanned during the vacuum? --

Re: [HACKERS] visibility map - what do i miss?

2008-12-06 Thread Heikki Linnakangas
Guillaume Smet wrote: On Sat, Dec 6, 2008 at 12:53 PM, hubert depesz lubaczewski <[EMAIL PROTECTED]> wrote: First run - without visibility maps, timing of vacuums: Time: 267844.822 ms Time: 138854.592 ms Time: 305467.950 ms Time: 487133.179 ms Second run - on head: Time: 252218.609 ms Time: 23

Re: [HACKERS] visibility map - what do i miss?

2008-12-06 Thread Guillaume Smet
On Sat, Dec 6, 2008 at 12:53 PM, hubert depesz lubaczewski <[EMAIL PROTECTED]> wrote: > First run - without visibility maps, timing of vacuums: > Time: 267844.822 ms > Time: 138854.592 ms > Time: 305467.950 ms > Time: 487133.179 ms > > Second run - on head: > > Time: 252218.609 ms > Time: 234388.76

[HACKERS] visibility map - what do i miss?

2008-12-06 Thread hubert depesz lubaczewski
--- repost to hackers as suggested by RhodiumToad --- hi, i tried to test new "visibility map" feature. to do so i: 1. fetched postgresql sources from cvs 2. compiled 3. turned autovacuum off 4. started pg 5. ran this queries: - CREATE TABLE test_1 (i INT4); - CREATE TABLE test_2 (i INT4);

Re: [HACKERS] Visibility map, partial vacuums

2008-12-03 Thread Gregory Stark
Gregory Stark <[EMAIL PROTECTED]> writes: > Heikki Linnakangas <[EMAIL PROTECTED]> writes: > >> Gregory Stark wrote: >>> 1) Raise autovacuum_max_freeze_age to 400M or 800M. Having it at 200M just >>>means unnecessary full table vacuums long before they accomplish >>> anything. >> >> It allows

Re: [HACKERS] Visibility map, partial vacuums

2008-12-03 Thread Heikki Linnakangas
Gregory Stark wrote: Heikki Linnakangas <[EMAIL PROTECTED]> writes: Gregory Stark wrote: Heikki Linnakangas <[EMAIL PROTECTED]> writes: Hmm. It just occurred to me that I think this circumvented the anti-wraparound vacuuming: a normal vacuum doesn't advance relfrozenxid anymore. We'll need to

Re: [HACKERS] Visibility map, partial vacuums

2008-12-03 Thread Gregory Stark
Heikki Linnakangas <[EMAIL PROTECTED]> writes: > Gregory Stark wrote: >> Heikki Linnakangas <[EMAIL PROTECTED]> writes: >> >>> Hmm. It just occurred to me that I think this circumvented the >>> anti-wraparound >>> vacuuming: a normal vacuum doesn't advance relfrozenxid anymore. We'll need >>> to

Re: [HACKERS] Visibility map, partial vacuums

2008-12-03 Thread Heikki Linnakangas
Gregory Stark wrote: Heikki Linnakangas <[EMAIL PROTECTED]> writes: Hmm. It just occurred to me that I think this circumvented the anti-wraparound vacuuming: a normal vacuum doesn't advance relfrozenxid anymore. We'll need to disable the skipping when autovacuum is triggered to prevent wraparou

Re: [HACKERS] Visibility map, partial vacuums

2008-12-03 Thread Magnus Hagander
Gregory Stark wrote: > Heikki Linnakangas <[EMAIL PROTECTED]> writes: > >> Hmm. It just occurred to me that I think this circumvented the >> anti-wraparound >> vacuuming: a normal vacuum doesn't advance relfrozenxid anymore. We'll need >> to >> disable the skipping when autovacuum is triggered t

Re: [HACKERS] Visibility map, partial vacuums

2008-12-03 Thread Alvaro Herrera
Heikki Linnakangas wrote: > Hmm. It just occurred to me that I think this circumvented the > anti-wraparound vacuuming: a normal vacuum doesn't advance relfrozenxid > anymore. We'll need to disable the skipping when autovacuum is triggered > to prevent wraparound. VACUUM FREEZE does that alr

Re: [HACKERS] Visibility map, partial vacuums

2008-12-03 Thread Gregory Stark
Heikki Linnakangas <[EMAIL PROTECTED]> writes: > Hmm. It just occurred to me that I think this circumvented the anti-wraparound > vacuuming: a normal vacuum doesn't advance relfrozenxid anymore. We'll need to > disable the skipping when autovacuum is triggered to prevent wraparound. > VACUUM > FR

Re: [HACKERS] Visibility map, partial vacuums

2008-12-03 Thread Heikki Linnakangas
Heikki Linnakangas wrote: Here's an updated version, with a lot of smaller cleanups, and using relcache invalidation to notify other backends when the visibility map fork is extended. I already committed the change to FSM to do the same. I'm feeling quite satisfied to commit this patch early ne

Re: [HACKERS] Visibility map, partial vacuums

2008-11-27 Thread Heikki Linnakangas
Heikki Linnakangas wrote: Here's an updated version, ... And here it is, for real... -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com *** src/backend/access/heap/Makefile --- src/backend/access/heap/Makefile *** *** 12,17 subdir = src/backend/access/heap

Re: [HACKERS] Visibility map, partial vacuums

2008-11-27 Thread Heikki Linnakangas
Tom Lane wrote: Heikki Linnakangas <[EMAIL PROTECTED]> writes: There is another problem, though, if the map is frequently probed for pages that don't exist in the map, or the map doesn't exist at all. Currently, the size of the map file is kept in relcache, in the rd_vm_nblocks_cache variable.

Re: [HACKERS] Visibility map, partial vacuums

2008-11-26 Thread Heikki Linnakangas
Tom Lane wrote: Heikki Linnakangas <[EMAIL PROTECTED]> writes: Tom Lane wrote: Well, considering how seldom new pages will be added to the visibility map, it seems to me we could afford to send out a relcache inval event when that happens. Then rd_vm_nblocks_cache could be treated as trustwort

Re: [HACKERS] Visibility map, partial vacuums

2008-11-26 Thread Tom Lane
Heikki Linnakangas <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> Well, considering how seldom new pages will be added to the visibility >> map, it seems to me we could afford to send out a relcache inval event >> when that happens. Then rd_vm_nblocks_cache could be treated as >> trustworthy. >

Re: [HACKERS] Visibility map, partial vacuums

2008-11-26 Thread Heikki Linnakangas
Tom Lane wrote: Heikki Linnakangas <[EMAIL PROTECTED]> writes: There is another problem, though, if the map is frequently probed for pages that don't exist in the map, or the map doesn't exist at all. Currently, the size of the map file is kept in relcache, in the rd_vm_nblocks_cache variable.

Re: [HACKERS] Visibility map, partial vacuums

2008-11-26 Thread Tom Lane
Heikki Linnakangas <[EMAIL PROTECTED]> writes: > There is another problem, though, if the map is frequently probed for > pages that don't exist in the map, or the map doesn't exist at all. > Currently, the size of the map file is kept in relcache, in the > rd_vm_nblocks_cache variable. Whenever

Re: [HACKERS] Visibility map, partial vacuums

2008-11-26 Thread Heikki Linnakangas
Tom Lane wrote: Heikki Linnakangas <[EMAIL PROTECTED]> writes: The visibility map won't be inquired unless you vacuum. This is a bit tricky. In vacuum, we only know whether we can set a bit or not, after we've acquired a cleanup lock on the page, and scanned all the tuples. While we're holding

Re: [HACKERS] Visibility map, partial vacuums

2008-11-25 Thread Decibel!
On Nov 23, 2008, at 3:18 PM, Tom Lane wrote: So it seems like we do indeed want to rejigger autovac's rules a bit to account for the possibility of wanting to apply vacuum to get visibility bits set. That makes the idea of not writing out hint bit updates unless the page is already dirty a l

Re: [HACKERS] Visibility map, partial vacuums

2008-11-24 Thread Tom Lane
Gregory Stark <[EMAIL PROTECTED]> writes: > So if it's possible for the frozenxid in the visibility map to go backwards > then it's no good, since if that update is lost we might skip a necessary > vacuum freeze. Seems like a lost disk write would be enough to make that happen. Now you might argu

Re: [HACKERS] Visibility map, partial vacuums

2008-11-24 Thread Gregory Stark
Heikki Linnakangas <[EMAIL PROTECTED]> writes: > Gregory Stark wrote: >> However I'm a bit puzzled how you could possibly maintain this frozenxid. As >> soon as you freeze an xid you'll have to visit all the other pages covered by >> that visibility map page to see what the new value should be. >

Re: [HACKERS] Visibility map, partial vacuums

2008-11-24 Thread Heikki Linnakangas
Gregory Stark wrote: However I'm a bit puzzled how you could possibly maintain this frozenxid. As soon as you freeze an xid you'll have to visit all the other pages covered by that visibility map page to see what the new value should be. Right, you could only advance it when you scan all the pa

Re: [HACKERS] Visibility map, partial vacuums

2008-11-24 Thread Gregory Stark
Tom Lane <[EMAIL PROTECTED]> writes: > Heikki Linnakangas <[EMAIL PROTECTED]> writes: >> I've been thinking that we could add one frozenxid field to each >> visibility map page, for the oldest xid on the heap pages covered by the >> visibility map page. That would allow more fine-grained anti-wr

Re: [HACKERS] Visibility map, partial vacuums

2008-11-24 Thread Tom Lane
Heikki Linnakangas <[EMAIL PROTECTED]> writes: > Tom Lane wrote: >> So it seems like we do indeed want to rejigger autovac's rules a bit >> to account for the possibility of wanting to apply vacuum to get >> visibility bits set. > I'm not too excited about triggering an extra vacuum. As Matthew po

Re: [HACKERS] Visibility map, partial vacuums

2008-11-24 Thread Tom Lane
Heikki Linnakangas <[EMAIL PROTECTED]> writes: > I've been thinking that we could add one frozenxid field to each > visibility map page, for the oldest xid on the heap pages covered by the > visibility map page. That would allow more fine-grained anti-wraparound > vacuums as well. This doesn't

Re: [HACKERS] Visibility map, partial vacuums

2008-11-24 Thread Heikki Linnakangas
Tom Lane wrote: * ISTM that the patch is designed on the plan that the PD_ALL_VISIBLE page header flag *must* be correct, but it's really okay if the backing map bit *isn't* correct --- in particular we don't trust the map bit when performing antiwraparound vacuums. This isn't well documented.

Re: [HACKERS] Visibility map, partial vacuums

2008-11-23 Thread Heikki Linnakangas
Tom Lane wrote: Reflecting on it though, maybe Heikki described the behavior too pessimistically anyway. If a page contains no dead tuples, it should get its bits set on first visit anyhow, no? So for the ordinary bulk load scenario where there are no failed insertions, the first vacuum pass sh

Re: [HACKERS] Visibility map, partial vacuums

2008-11-23 Thread Matthew T. O'Connor
Tom Lane wrote: However, my comment above was too optimistic, because in an insert-only scenario autovac would in fact not trigger VACUUM at all, only ANALYZE. So it seems like we do indeed want to rejigger autovac's rules a bit to account for the possibility of wanting to apply vacuum to get vi

Re: [HACKERS] Visibility map, partial vacuums

2008-11-23 Thread Tom Lane
Jeff Davis <[EMAIL PROTECTED]> writes: > On Sun, 2008-11-23 at 14:05 -0500, Tom Lane wrote: >> A possible problem is that if a relation is filled all in one shot, >> autovacuum would trigger a single vacuum cycle on it and then never have >> a reason to trigger another; leading to the bits never ge

Re: [HACKERS] Visibility map, partial vacuums

2008-11-23 Thread Jeff Davis
On Sun, 2008-11-23 at 14:05 -0500, Tom Lane wrote: > A possible problem is that if a relation is filled all in one shot, > autovacuum would trigger a single vacuum cycle on it and then never have > a reason to trigger another; leading to the bits never getting set (or > at least not till an antiwra

Re: [HACKERS] Visibility map, partial vacuums

2008-11-23 Thread Tom Lane
Heikki Linnakangas <[EMAIL PROTECTED]> writes: > I committed the changes to FSM truncation yesterday, that helps with the > truncation of the visibility map as well. Attached is an updated > visibility map patch. I looked over this patch a bit ... > 1. The bits in the visibility map are set in

Re: [HACKERS] Visibility map, partial vacuums

2008-11-20 Thread Heikki Linnakangas
I committed the changes to FSM truncation yesterday, that helps with the truncation of the visibility map as well. Attached is an updated visibility map patch. There's two open issues: 1. The bits in the visibility map are set in the 1st phase of lazy vacuum. That works, but it means that aft

Re: [HACKERS] Visibility map, partial vacuums

2008-11-14 Thread Gregory Stark
Heikki Linnakangas <[EMAIL PROTECTED]> writes: > The next question is whether the "pending rel deletion" stuff in smgr.c should > be moved to the new file too. It seems like it would belong there better. That > would leave smgr.c as a very thin wrapper around md.c Well it's just a switch, albeit

Re: [HACKERS] Visibility map, partial vacuums

2008-11-14 Thread Heikki Linnakangas
Heikki Linnakangas wrote: Another thing that does need to be fixed, is the way that the extension and truncation of the visibility map is handled; that's broken in the current patch. I started working on the patch a long time ago, before the FSM rewrite was finished, and haven't gotten around f

Re: [HACKERS] Visibility map, partial vacuums

2008-10-28 Thread Simon Riggs
On Tue, 2008-10-28 at 13:58 -0400, Tom Lane wrote: > Simon Riggs <[EMAIL PROTECTED]> writes: > > On Mon, 2008-10-27 at 14:03 +0200, Heikki Linnakangas wrote: > >> Lazy VACUUM only needs to visit pages that are '0' in the visibility > >> map. This allows partial vacuums, where we only need to scan

Re: [HACKERS] Visibility map, partial vacuums

2008-10-28 Thread Tom Lane
Heikki Linnakangas <[EMAIL PROTECTED]> writes: > Yes, but there's a problem with recently inserted tuples: > 1. A query begins in the slave, taking a snapshot with xmax = 100. So > the effects of anything more recent should not be seen. > 2. Transaction 100 inserts a tuple in the master, and comm

Re: [HACKERS] Visibility map, partial vacuums

2008-10-28 Thread Tom Lane
Simon Riggs <[EMAIL PROTECTED]> writes: > On Mon, 2008-10-27 at 14:03 +0200, Heikki Linnakangas wrote: >> Lazy VACUUM only needs to visit pages that are '0' in the visibility >> map. This allows partial vacuums, where we only need to scan those parts >> of the table that need vacuuming, plus all

Re: [HACKERS] Visibility map, partial vacuums

2008-10-28 Thread Simon Riggs
On Tue, 2008-10-28 at 19:02 +0200, Heikki Linnakangas wrote: > Yes, but there's a problem with recently inserted tuples: > > 1. A query begins in the slave, taking a snapshot with xmax = 100. So > the effects of anything more recent should not be seen. > 2. Transaction 100 inserts a tuple in th

Re: [HACKERS] Visibility map, partial vacuums

2008-10-28 Thread Simon Riggs
On Mon, 2008-10-27 at 14:03 +0200, Heikki Linnakangas wrote: > Lazy VACUUM only needs to visit pages that are '0' in the visibility > map. This allows partial vacuums, where we only need to scan those parts > of the table that need vacuuming, plus all indexes. Just realised that this means we

Re: [HACKERS] Visibility map, partial vacuums

2008-10-28 Thread Heikki Linnakangas
Simon Riggs wrote: On Tue, 2008-10-28 at 14:57 +0200, Heikki Linnakangas wrote: Simon Riggs wrote: On Mon, 2008-10-27 at 14:03 +0200, Heikki Linnakangas wrote: One option would be to just ignore that problem for now, and not WAL-log. Probably worth skipping for now, since it will cause patch

Re: [HACKERS] Visibility map, partial vacuums

2008-10-28 Thread Simon Riggs
On Tue, 2008-10-28 at 14:57 +0200, Heikki Linnakangas wrote: > Simon Riggs wrote: > > On Mon, 2008-10-27 at 14:03 +0200, Heikki Linnakangas wrote: > >> One option would be to just ignore that problem for now, and not > >> WAL-log. > > > > Probably worth skipping for now, since it will cause patc

Re: [HACKERS] Visibility map, partial vacuums

2008-10-28 Thread Heikki Linnakangas
Tom Lane wrote: Heikki Linnakangas <[EMAIL PROTECTED]> writes: To modify a page: If PD_ALL_VISIBLE flag is set, the bit in the visibility map is cleared first. The heap page is kept pinned, but not locked, while the visibility map is updated. We want to avoid holding a lock across I/O, even t

Re: [HACKERS] Visibility map, partial vacuums

2008-10-28 Thread Heikki Linnakangas
Tom Lane wrote: The harder part is propagating the bit to the visibility map, but I gather you intend to only allow VACUUM to do that? Yep. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make change

  1   2   >