pgsql: Improve scalability of md.c for large relations.

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve scalability of md.c for large relations.
Date: 2016-09-09 00:22:35
Message-ID: E1bi9aV-0005L1-LQ@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve scalability of md.c for large relations.

So far md.c used a linked list of segments. That proved to be a problem
when processing large relations, because every smgr.c/md.c level access
to a page incurred walking through a linked list of all preceding
segments. Thus making accessing pages O(#segments).

Replace the linked list of segments hanging off SMgrRelationData with an
array of opened segments. That allows O(1) access to individual
segments, if they've previously been opened.

Discussion: <20140331101001(dot)GE13135(at)alap3(dot)anarazel(dot)de>
Reviewed-By: Peter Geoghegan, Tom Lane (in an older version)

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/45e191e3aa62d47a8bc1a33f784286b2051f45cb

Modified Files
--------------
src/backend/storage/smgr/md.c | 393 ++++++++++++++++++++++------------------
src/backend/storage/smgr/smgr.c | 4 +-
src/include/storage/smgr.h | 8 +-
3 files changed, 229 insertions(+), 176 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Simon Riggs 2016-09-09 10:20:59 pgsql: Correct TABLESAMPLE docs
Previous Message Andres Freund 2016-09-08 23:54:16 pgsql: Fix mdtruncate() to close fd.c handle of deleted segments.