Creating multiple indexes in one table scan.

From: Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com>
To: PGSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Creating multiple indexes in one table scan.
Date: 2012-05-24 11:51:36
Message-ID: CABwTF4VojjxFzBUWb_V8ytDViMj4CPQ0ESw-nfBJO73FyBkp0Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I was going though the minutes of PGCon 2012 DEveloper Meeting [1] and came
across this:
Bruce points out the even simpler case is to build several indexes in
parallel over the same scan.

I thought I had posted a patch to that effect long back, but upon searching
my emails apparently I forgot about the patch.

Attached is the patch that I developed in Nov. 2010, so expect a lot of bit
rot. I had tried to make it elegant, but I have to admit its a hack. This
patch does not imply that it is using any kind of parallelism, the context
in which that above statement was made. It just helps to avoid scanning the
same relation multiple times. I performed some tests on it and AFAICR, this
did not produce a net win. But those tests may have been performed in a
virtual machine and not on a bare metal, I forget.

AFAICR, this is how it works:

.) It introduces a new type of SQL statement:
CREATE INDEX ....., CREATE INDEX ..., CREATE INDEX.

That is, it makes it legal to join multiple CREATE INDEX statements,
separated by comma.

.) During the execution phase (IndexBuildHeapScan()), it gathers all the
statements in a stack-like data structure before processing any tuples from
the heap.

.) When done gathering all the CREATE INDEX statements, it proceeds to
process the heap.

.) For each heap tuple it calls each index's build method as usual.

Best regards,

PS: Please expect intermittent replies over the next few days.

[1] http://wiki.postgresql.org/wiki/PgCon_2012_Developer_Meeting
--
Gurjeet Singh
EnterpriseDB Corporation
The Enterprise PostgreSQL Company

Attachment Content-Type Size
create_multi_index.day2feature_complete.zip application/zip 4.4 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2012-05-24 12:05:14 Re: pg_receivexlog stops upon server restart
Previous Message Magnus Hagander 2012-05-24 11:42:20 Re: pg_stat_statements temporary file