_mdfd_getseg can be expensive - Mailing list pgsql-hackers

From Andres Freund
Subject _mdfd_getseg can be expensive
Date
Msg-id 20140331101001.GE13135@alap3.anarazel.de
Whole thread Raw
Responses Re: _mdfd_getseg can be expensive  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers
Hi,

I recently have seen some perf profiles in which _mdfd_getseg() was in
the top #3 when VACUUMing large (~200GB) relations. Called by mdread(),
mdwrite(). Looking at it's implementation, I am not surprised. It
iterates over all segment entries a relations has; for every read or
write. That's not painful for smaller relations, but at a couple of
hundred GB it starts to be annoying. Especially if kernel readahead has
already read in all data from disk.

I don't have a good idea what to do about this yet, but it seems like
something that should be fixed mid-term.

The best I can come up is is caching the last mdvec used, but that's
fairly ugly. Alternatively it might be a good idea to not store MdfdVec
as a linked list, but as a densely allocated array.

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Etsuro Fujita
Date:
Subject: Re: inherit support for foreign tables
Next
From: Thom Brown
Date:
Subject: Re: B-Tree support function number 3 (strxfrm() optimization)