pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Charles Clavadetscher <clavadetscher@swisspug.org>
To: Greg Sabino Mullane <greg@turnstep.com>
To: pgsql-general@postgresql.org
Cc: patrickbakerbr@gmail.com
Subject: Re: pg_sample
Date: Tue, 18 Oct 2016 21:05:20 -0700
Message-ID: <3f409be2-cebf-2dc8-52dd-7f432f34c385@aklaver.com> (raw)
In-Reply-To: <2956c916-a8e0-36d7-20e0-499cca6b4bc6@swisspug.org>
References: <f7ca973dc47a6d83bc48a8f78f7d0987@biglumber.com>
	<2956c916-a8e0-36d7-20e0-499cca6b4bc6@swisspug.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>

On 10/18/2016 08:15 PM, Charles Clavadetscher wrote:
> Hello
>
> On 10/19/2016 04:58 AM, Greg Sabino Mullane wrote:
>>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: RIPEMD160
>>
>>
>> Patrick B <patrickbakerbr@gmail.com> writes:
>> ...
>>> However, this new database test server doesn't need to have all the
>>> data. I
>>> would like to have only the first 100 rows(example) of each table in my
>>> database.
>> ...
>>
>> This should do what you ask.
>>
>> If the order does not matter, leave out the ORDER BY.
>>
>> This assumes everything of interest is in the public schema.
>>
>> $ createdb testdb
>> $ pg_dump realdb --schema-only | psql -q testdb
>> $ psql realdb
>>
>> psql> \o dump.some.rows.sh
>> psql> select format($$psql realdb -c 'COPY (select * from %I order by
>> 1 limit %s) TO STDOUT' | psql testdb -c 'COPY %I FROM STDIN' $$,
>> table_name, 100, table_name)
>>       from information_schema.tables where table_schema = 'public' and
>> table_type = 'BASE TABLE';
>> psql> \q
>>
>> $ sh dump.some.rows.sh
>
> I may be overseeing something, but what about dependencies between
> tables, sequencies, indexes, etc.? I guess that if one takes the first
> 100 rows of a table referenced by another table, there is no guarantee
> that in the first 100 rows of the referencing table there will not be
> some foreign key that does not exist.

Well there is:

https://github.com/18F/rdbms-subsetter

That still does not guarantee that the rows selected cover your test 
cases though.

>
> Regards
> Charles
>
>>
>> - --
>> Greg Sabino Mullane greg@turnstep.com
>> End Point Corporation http://www.endpoint.com/
>> PGP Key: 0x14964AC8 201610182256
>> http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
>> -----BEGIN PGP SIGNATURE-----
>>
>> iEYEAREDAAYFAlgG4NkACgkQvJuQZxSWSsge4ACePhBOBtBFnGNxXt5qpY7X+w3o
>> d04AoKTzAgxcaqy8qfIE0LPuzG9x0KIU
>> =sS+m
>> -----END PGP SIGNATURE-----
>>
>>
>>
>>
>


-- 
Adrian Klaver
adrian.klaver@aklaver.com


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



view thread (25+ messages)  latest in thread

Message-ID: <3f409be2-cebf-2dc8-52dd-7f432f34c385@aklaver.com>
Permalink:  ../3f409be2-cebf-2dc8-52dd-7f432f34c385@aklaver.com/
Also on:    postgresql.org/message-id/3f409be2-cebf-2dc8-52dd-7f432f34c385@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, clavadetscher@swisspug.org, greg@turnstep.com, patrickbakerbr@gmail.com
  Subject: Re: pg_sample
  In-Reply-To: <3f409be2-cebf-2dc8-52dd-7f432f34c385@aklaver.com>
  References: <f7ca973dc47a6d83bc48a8f78f7d0987@biglumber.com> <2956c916-a8e0-36d7-20e0-499cca6b4bc6@swisspug.org> <3f409be2-cebf-2dc8-52dd-7f432f34c385@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox