Re: Is stats update during COPY IN really a good idea?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Is stats update during COPY IN really a good idea?
Date: 2001-05-21 17:41:50
Message-ID: 200105211741.f4LHfpK03622@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> We have a TODO item
> * Update reltuples in COPY
>
> I was just about to go do this when I realized that it may not be such
> a hot idea after all. The problem is that updating pg_class.reltuples
> means that concurrent COPY operations will block each other, because
> they want to update the same row in pg_class. You can already see this
> happen in CREATE INDEX:

People are using COPY into the same table at the same time?

> While this doesn't bother me for CREATE INDEX, it does bother me for
> COPY, since people often use COPY to avoid per-tuple INSERT overhead.
> It seems pretty likely that this will cause blocking problems for real
> applications. I think that may be a bigger problem than the benefit of
> not needing a VACUUM (or, now, ANALYZE) to get the stats updated.

Oh, well we can either decide to do it or remove the TODO item. Either
way we win!

My vote is to update pg_class. The VACUUM takes much more time than the
update, and we are only updating the pg_class row, right? Can't we just
start a new transaction and update the pg_class row, that way we don't
have to open it for writing during the copy.

FYI, I had a 100k deep directory that caused me problems this morning.
Just catching up.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-05-21 17:42:40 Re: AW: Fix for tablename in targetlist
Previous Message Trond Eivind =?iso-8859-1?q?Glomsr=F8d?= 2001-05-21 17:38:46 Re: Using 7.1rc1 under RH 6.2