diff options
author | Andres Freund <andres@anarazel.de> | 2016-09-08 17:02:43 -0700 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2016-09-08 17:18:46 -0700 |
commit | 45e191e3aa62d47a8bc1a33f784286b2051f45cb (patch) | |
tree | a758d62f63c4123052167b2aa6baa1cb551c0dbc /src/include | |
parent | 417fefaf089fc0b73607cbbe8bcd0bc9e89d08ef (diff) |
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.GE13135@alap3.anarazel.de>
Reviewed-By: Peter Geoghegan, Tom Lane (in an older version)
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/storage/smgr.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h index a8e7877f704..3430d8665e4 100644 --- a/src/include/storage/smgr.h +++ b/src/include/storage/smgr.h @@ -64,8 +64,12 @@ typedef struct SMgrRelationData */ int smgr_which; /* storage manager selector */ - /* for md.c; NULL for forks that are not open */ - struct _MdfdVec *md_fd[MAX_FORKNUM + 1]; + /* + * for md.c; per-fork arrays of the number of open segments + * (md_num_open_segs) and the segments themselves (md_seg_fds). + */ + int md_num_open_segs[MAX_FORKNUM + 1]; + struct _MdfdVec *md_seg_fds[MAX_FORKNUM + 1]; /* if unowned, list link in list of all unowned SMgrRelations */ struct SMgrRelationData *next_unowned_reln; |