Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WK63A-00065P-Uo for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Mar 2014 13:03:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WK63A-0000Sx-9G for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Mar 2014 13:03:24 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WK636-0000RR-HG; Sun, 02 Mar 2014 13:03:20 +0000 Received: from mail-pd0-x232.google.com ([2607:f8b0:400e:c02::232]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WK632-000584-9Q; Sun, 02 Mar 2014 13:03:19 +0000 Received: by mail-pd0-f178.google.com with SMTP id x10so2617801pdj.23 for ; Sun, 02 Mar 2014 05:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=Krz2TUF3CFLk0VohYaWgOCpH8wQ/QTPKDUBl0+mMhy8=; b=diJSClXcQVFrqZEzFfc8DFNjCVS5kkELnIeFFpZ5nzKCEMtIxL6frhasU8Mwwjjsds Z4dv79iu4kqNQH78YXqbOozyfYOjUd2RjBaad1j6rGOWrnBRGnLGXbUWxoNuzjxepQuz vQraYpM1ABEOXg9iRZCEIrRi2tpekUNR/SYDx8tV+z8TsM9mLJsJ2ycNMn5YYexocV5D ynsu8hrytFMPASJ87aPb1Xabk/xhjeb1ew3tu7zQ2iMnSidkd9gEpizN06gZSFbnbk8O ZtpMxcw8nVMSbwm0YYWf98KD9iVba40lXHSC1E3i/9VR5oo8aiZNI4dKLx95++3goZTh v5Tw== X-Received: by 10.68.108.1 with SMTP id hg1mr14038167pbb.80.1393765394333; Sun, 02 Mar 2014 05:03:14 -0800 (PST) Received: from [10.0.0.6] (pool-173-51-130-99.lsanca.fios.verizon.net. [173.51.130.99]) by mx.google.com with ESMTPSA id op3sm25326660pbc.40.2014.03.02.05.03.13 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Mar 2014 05:03:13 -0800 (PST) Content-Type: multipart/alternative; boundary="Apple-Mail=_E243349E-A33C-424B-B17E-B490331F9F35" Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) Subject: Re: GSoC 2014 - mentors, students and admins From: Tan Tran In-Reply-To: Date: Sun, 2 Mar 2014 05:03:14 -0800 Cc: pgsql-advocacy , PostgreSQL-development Message-Id: References: To: Greg Stark X-Mailer: Apple Mail (2.1827) X-Pg-Spam-Score: -2.0 (--) 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 --Apple-Mail=_E243349E-A33C-424B-B17E-B490331F9F35 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 Hi Greg, pgsql-advocacy, and pgsql-hackers, I'm interested in doing my GSoC project on this idea. I'm new to = indexing and WAL, which I haven't encountered in my classes, but it = sounds interesting and valuable to Postgresql. So here's my draft = proposal. Do you mind giving your opinion and corrections? With your = help I'll add some technical detail to my plans. Thanks, Tan Tran Introduction In write-ahead logging (WAL), all modifications to a database = are written to a write-ahead log before being flushed to disk at = periodic checkpoints. This method saves I/O operations, enables a = continuous backup, and, in the case of database failure, guarantees data = integrity up until the last saved checkpoint. In Postgresql=92s = implementation, transactions are written to XLog, which is divided into = 16MB files (=93segments=94) that together comprise a complete history of = transactions. Transactions are continually appended to the latest = segment, while checkpointing continually archives segments up until the = last checkpoint. Internally, a suite of XLog structures and functions = interfaces with the various resource managers so they can log a = sufficient amount of data to restore data (=93redo=94) in case of = failure. Another Postgresql feature is the creation of indexes on a = invariant custom field; for example, on the LastName of a Person even = though the primary key is ID. These custom indexes speed up row lookup. = Postgres currently supports four index types: B-tree, GiST, and GIN, and = hash. Indexes on the former three are WAL-recoverable, but hashing is = not. 2. Proposal As a GSoC student, I will implement WAL recovery of hash indexes = using the other index types=92 WAL code as a guide. Roughly, I will: - Devise a way to store and retrieve hashing data within the XLog data = structures.=20 - In the existing skeleton for hash_redo(XLogRecPtr lsn, XLogRecord = *record) in hash.c, branch to code for the various redo operations: = creating an index, inserting into an index, deleting an index, and page = operations (split, delete, update?). - Code each branch by drawing on examples from btree_redo, gin_redo, and = gist_redo, the existing XLog code of the other index types. Benefits Hash index searching is O(1), which is asymptotically faster than the = O(n lg n) searching of a B-tree, and does not require custom indexing = functions like GIN and GIST inherently do. Therefore it is desirable for = rows that will only be retrieved on an equality or inequality relation. = However, two things currently stand in the way of its popular use. =46rom = the Postgresql documentation, =93Hash index operations are not presently WAL-logged, so hash = indexes might need to be rebuilt with REINDEX after a database crash if = there were unwritten changes. Also, changes to hash indexes are not = replicated over streaming or file-based replication after the initial = base backup, so they give wrong answers to queries that subsequently use = them. For these reasons, hash index use is presently discouraged.=94 My project would solve the first problem, after which I would like to = stay on and fix the second. To be written: Quantifiable Results, Schedule, Completeness Criteria, = Bio On Feb 28, 2014, at 6:21 AM, Greg Stark wrote: > On Tue, Jan 28, 2014 at 5:34 PM, Thom Brown wrote: >> Who would be up for mentoring this year? And are there any project >> ideas folk would like to suggest? >=20 > I mentored in the past and felt I didn't do a very good job because I > didn't really understand the project the student was working on. >=20 > There's precisely one project that I feel I would be competent to > mentor at this point. Making hash indexes WAL recoverable. This is > something that's easy to define the scope of and easy to determine if > the student is on track and easy to measure when finished. It's > something where as far as I can tell all the mentor work will be > purely technical advice. >=20 > Also it's something the project really really needs and is perfectly > sized for a GSOC project IMHO. Also it's a great project for a student > who might be interested in working on Postgres in the future since it > requires learning all our idiosyncratic build and source conventions > but doesn't require huge or controversial architectural changes. >=20 > I fear a number of items in the Wiki seem unrealistically large > projects for GSOC IMNSHO. >=20 > --=20 > greg >=20 >=20 > --=20 > Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-hackers --Apple-Mail=_E243349E-A33C-424B-B17E-B490331F9F35 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252 Hi = Greg, pgsql-advocacy, and pgsql-hackers,

I'm = interested in doing my GSoC project on this idea. I'm new to indexing = and WAL, which I haven't encountered in my classes, but it sounds = interesting and valuable to Postgresql. So here's my draft proposal. Do = you mind giving your opinion and corrections? With your help I'll add = some technical detail to my = plans.

Thanks,
Tan = Tran

Introduction
In write-ahead logging (WAL), all = modifications to a database are written to a write-ahead log before = being flushed to disk at periodic checkpoints. This method saves I/O = operations, enables a continuous backup, and, in the case of database = failure, guarantees data integrity up until the last saved checkpoint. = In Postgresql=92s implementation, transactions are written to XLog, = which is divided into 16MB files (=93segments=94) that together comprise = a complete history of transactions. Transactions are continually = appended to the latest segment, while checkpointing continually archives = segments up until the last checkpoint. Internally, a suite of XLog = structures and functions interfaces with the various resource managers = so they can log a sufficient amount of data to restore data (=93redo=94) = in case of failure.
Another Postgresql feature is the = creation of indexes on a invariant custom field; for example, on the = LastName of a Person even though the primary key is ID. These custom = indexes speed up row lookup. Postgres currently supports four index = types: B-tree, GiST, and GIN, and hash. Indexes on the former three are = WAL-recoverable, but hashing is not.

2. Proposal
As a GSoC = student, I will implement WAL recovery of hash indexes using the other = index types=92 WAL code as a guide. Roughly, I will:
- Devise a = way to store and retrieve hashing data within the XLog data = structures. 
- In the existing skeleton for = hash_redo(XLogRecPtr lsn, XLogRecord *record) in hash.c, branch to code = for the various redo operations: creating an index, inserting into an = index, deleting an index, and page operations (split, delete, = update?).
- Code each branch by drawing on = examples from btree_redo, gin_redo, and gist_redo, the existing XLog = code of the other index types.

Benefits
Hash index searching is = O(1), which is asymptotically faster than the O(n lg n) searching of a = B-tree, and does not require custom indexing functions like GIN and GIST = inherently do. Therefore it is desirable for rows that will only be = retrieved on an equality or inequality relation. However, two things = currently stand in the way of its popular use. =46rom the Postgresql = documentation,
=93Hash index operations are not = presently WAL-logged, so hash indexes might need to be rebuilt with = REINDEX after a database crash if there were unwritten changes. Also, = changes to hash indexes are not replicated over streaming or file-based = replication after the initial base backup, so they give wrong answers to = queries that subsequently use them. For these reasons, hash index use is = presently discouraged.=94
My project would solve the first = problem, after which I would like to stay on and fix the = second.

To be written: Quantifiable = Results, Schedule, Completeness Criteria, Bio


On Feb 28, = 2014, at 6:21 AM, Greg Stark <stark@mit.edu> wrote:

On Tue, = Jan 28, 2014 at 5:34 PM, Thom Brown <thom@linux.com> = wrote:
Who would be up for mentoring this = year?  And are there any project
ideas folk would like to = suggest?

I mentored in the past and felt I didn't do = a very good job because I
didn't really understand the project the = student was working on.

There's precisely one project that I feel = I would be competent to
mentor at this point. Making hash indexes WAL = recoverable. This is
something that's easy to define the scope of and = easy to determine if
the student is on track and easy to measure when = finished. It's
something where as far as I can tell all the mentor = work will be
purely technical advice.

Also it's something the = project really really needs and is perfectly
sized for a GSOC project = IMHO. Also it's a great project for a student
who might be interested = in working on Postgres in the future since it
requires learning all = our idiosyncratic build and source conventions
but doesn't require = huge or controversial architectural changes.

I fear a number of = items in the Wiki seem unrealistically large
projects for GSOC = IMNSHO.

--
greg


--
Sent via pgsql-hackers = mailing list (pgsql-hackers@postgresql.org<= /a>)
To make changes to your subscription:
http://www.postg= resql.org/mailpref/pgsql-hackers

= --Apple-Mail=_E243349E-A33C-424B-B17E-B490331F9F35--