Re: slow dropping of tables, DropRelFileNodeBuffers, tas

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: slow dropping of tables, DropRelFileNodeBuffers, tas
Дата
Msg-id 4FC6003F.9020408@enterprisedb.com
обсуждение исходный текст
Ответ на slow dropping of tables, DropRelFileNodeBuffers, tas  (Sergey Koposov <koposov@ast.cam.ac.uk>)
Ответы Re: slow dropping of tables, DropRelFileNodeBuffers, tas  (Robert Haas <robertmhaas@gmail.com>)
Re: slow dropping of tables, DropRelFileNodeBuffers, tas  (Jeff Janes <jeff.janes@gmail.com>)
Re: slow dropping of tables, DropRelFileNodeBuffers, tas  (Ants Aasma <ants@cybertec.at>)
Re: slow dropping of tables, DropRelFileNodeBuffers, tas  (Simon Riggs <simon@2ndQuadrant.com>)
Список pgsql-hackers
On 30.05.2012 03:40, Sergey Koposov wrote:
> I was running some tests on PG9.2beta where I'm creating and dropping
> large number of tables (~ 20000).
>
> And I noticed that table dropping was extremely slow -- e.g. like half a
> second per table.
>
> ...
>
> I also stopped PG with gdb a few times and it was always at this backtrace:
>
> (gdb) bt
> #0 tas (lock=0x7fa4e3007538 "\001") at
> ../../../../src/include/storage/s_lock.h:218
> #1 0x00000000006e6956 in DropRelFileNodeBuffers (rnode=...,
> forkNum=VISIBILITYMAP_FORKNUM, firstDelBlock=0) at bufmgr.c:2062
> #2 0x000000000070c014 in smgrdounlink (reln=0x1618210,
> forknum=VISIBILITYMAP_FORKNUM, isRedo=0 '\000') at smgr.c:354
> #3 0x000000000051ecf6 in smgrDoPendingDeletes (isCommit=1 '\001') at
> storage.c:364

Hmm, we do this in smgrDoPendingDeletes:

for (i = 0; i <= MAX_FORKNUM; i++)
{smgrdounlink(srel, i, false);
}

So we drop the buffers for each relation fork separately, which means 
that we scan the buffer pool four times. Relation forks in 8.4 
introduced that issue, and 9.1 made it worse by adding another fork for 
unlogged tables. With some refactoring, we could scan the buffer pool 
just once. That would help a lot.

Also, I wonder if DropRelFileNodeBuffers() could scan the pool without 
grabbing the spinlocks on every buffer? It could do an unlocked test 
first, and only grab the spinlock on buffers that need to be dropped.

--   Heikki Linnakangas  EnterpriseDB   http://www.enterprisedb.com


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Atri Sharma
Дата:
Сообщение: How do I get the name of the relation on which FDW has been called?
Следующее
От: Shigeru HANADA
Дата:
Сообщение: Re: How do I get the name of the relation on which FDW has been called?