Skip site navigation (1) Skip section navigation (2)

Re: COPY (query) TO file

From: "Mark Woodward" <pgsql(at)mohawksoft(dot)com>
To: "Tino Wildenhain" <tino(at)wildenhain(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: COPY (query) TO file
Date: 2006-06-02 14:23:30
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
> Mark Woodward wrote:
>>> Mark Woodward wrote:
>>>> Tom had posted a question about file compression with copy. I thought
>>>> about it, and I want to through this out and see if anyone things it
>>>> is
>>>> a
>>>> good idea.
>>>> Currently, the COPY command only copies a table, what if it could
>>>> operate
>>>> with a query, as:
>>>> COPY (select * from mytable where foo='bar') as BAR TO stdout
>>>> I have no idea if it is doable, but I can see uses for replication
>>> I doubt it be really usefull (apart from maybe saving some work
>>> coding a client app) but did you actually test it with
>>> create table as select ...; followed by a copy of that table
>>> if it really is faster then just the usual select & fetch?
>> Why "create table?"
> Just to simulate and time the proposal.
> SELECT ... already works over the network and if COPY from a
> select (which would basically work like yet another wire
> protocol) isnt significantly faster, why bother?

Because the format of COPY is a common transmiter/receiver for PostgreSQL,
like this:

pg_dump -t mytable | psql -h target -c "COPY mytable FROM STDIN"

With a more selective copy, you can use pretty much this mechanism to
limit a copy to a sumset of the records in a table.

>> The idea is that you would have one or more redundent databases and use
>> the COPY TO/FROM to keep them up to date.
> Well, if you have databases you would have regular tables - and
> can use copy as it is now :-)

But COPY copies all the records, not some of the records.
> Regards
> Tino

In response to


pgsql-hackers by date

Next:From: Stefan KaltenbrunnerDate: 2006-06-02 14:23:41
Subject: Re: COPY (query) TO file
Previous:From: Tino WildenhainDate: 2006-06-02 14:04:45
Subject: Re: COPY (query) TO file

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group