Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WUZAN-0005tS-47 for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Mar 2014 10:10:07 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WUZAM-00078f-KQ for pgsql-hackers@arkaria.postgresql.org; Mon, 31 Mar 2014 10:10:06 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WUZAL-00078W-6N for pgsql-hackers@postgresql.org; Mon, 31 Mar 2014 10:10:05 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WUZAI-0003vr-OC for pgsql-hackers@postgresql.org; Mon, 31 Mar 2014 10:10:04 +0000 Received: from andres.at.anarazel.de.authenticated.anarazel.de by mail.anarazel.de (Postfix) with ESMTPSA id 8F1114E8003 for ; Mon, 31 Mar 2014 12:10:01 +0200 (CEST) Date: Mon, 31 Mar 2014 12:10:01 +0200 From: Andres Freund To: pgsql-hackers@postgresql.org Subject: _mdfd_getseg can be expensive Message-ID: <20140331101001.GE13135@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org 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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers