Re: Restore v. Running COPY/INDEX seperatly

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gregory Stark <stark(at)enterprisedb(dot)com>, Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>, Benjamin Arai <me(at)benjaminarai(dot)com>, PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: Restore v. Running COPY/INDEX seperatly
Date: 2007-08-27 04:30:27
Message-ID: 20070827043027.GA18738@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> >> On Sun, 26 Aug 2007, Benjamin Arai wrote:
> >>> So, I built my tables which contains a TSearch2 field by
> >>> 1. Create table without indexes
> >>> 2. COPY data into table
> >>> 3. ALTER TABLE tblMessages ADD COLUMN idxFTI tsvector;
> >>> 4. UPDATE tblMessages SET idxFTI=to_tsvector('default', strMessage);
>
> > Or you could set up a trigger to generate the tsvector when you first
> > load the data instead of adding it later.
>
> You're going to want such a trigger anyway, so installing it before the
> COPY step seems like the Obviously Right Thing. Any other approach
> implies rewriting the entire table after you've loaded it, with no
> compensating advantage that I can see.

Isn't the main speed advantage of the dump the fact that the
to_tsvector() results already come in the COPY data? The dump already
comes with the idxFTI column contents, instead of having to generate it
from scratch. That would depend on how expensive that function is, of
course.

--
Alvaro Herrera http://www.amazon.com/gp/registry/DXLWNGRJD34J
"PHP is what I call the "Dumb Monkey" language. [A]ny dumb monkey can code
something in PHP. Python takes actual thought to produce something useful."
(J. Drake)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Fetter 2007-08-27 04:56:26 == PostgreSQL Weekly News - August 26 2007 ==
Previous Message Ow Mun Heng 2007-08-27 03:55:00 Re: Insert or Replace or \copy (bulkload)