_mdfd_getseg can be expensive

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: _mdfd_getseg can be expensive
Date: 2014-03-31 10:10:01
Message-ID: 20140331101001.GE13135@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


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.


Andres Freund

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


Browse pgsql-hackers by date

  From Date Subject
Next Message Thom Brown 2014-03-31 10:32:11 Re: B-Tree support function number 3 (strxfrm() optimization)
Previous Message Etsuro Fujita 2014-03-31 10:06:16 Re: inherit support for foreign tables