Skip to content

Commit e02d1ab

Browse files
committed
During swap_relfilenodes, swap relation size statistic fields along with
the relfilenode and toast fields. This ensures that the newly-computed statistics will be available on completion of CLUSTER.
1 parent 5123139 commit e02d1ab

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/backend/commands/cluster.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.90 2002/09/04 20:31:14 momjian Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.91 2002/11/02 21:20:40 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -475,6 +475,20 @@ swap_relfilenodes(Oid r1, Oid r2)
475475

476476
/* we should not swap reltoastidxid */
477477

478+
/* swap size statistics too, since new rel has freshly-updated stats */
479+
{
480+
int4 swap_pages;
481+
float4 swap_tuples;
482+
483+
swap_pages = relform1->relpages;
484+
relform1->relpages = relform2->relpages;
485+
relform2->relpages = swap_pages;
486+
487+
swap_tuples = relform1->reltuples;
488+
relform1->reltuples = relform2->reltuples;
489+
relform2->reltuples = swap_tuples;
490+
}
491+
478492
/* Update the tuples in pg_class */
479493
simple_heap_update(relRelation, &reltup1->t_self, reltup1);
480494
simple_heap_update(relRelation, &reltup2->t_self, reltup2);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy