Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bwi89-0002so-1T for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2016 04:05:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bwi88-0006R9-CJ for pgsql-general@arkaria.postgresql.org; Wed, 19 Oct 2016 04:05:28 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bwi86-0006Qa-KT for pgsql-general@postgresql.org; Wed, 19 Oct 2016 04:05:26 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bwi83-0006d3-DF for pgsql-general@postgresql.org; Wed, 19 Oct 2016 04:05:25 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 497C120592; Wed, 19 Oct 2016 00:05:22 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute3.internal (MEProxy); Wed, 19 Oct 2016 00:05:22 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=aklaver.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=GkCTMjFkOHx/XzFVwqMga9gusfA=; b=iyqAdf XUKVKa8Al3BG1U9NUq8MObkqZDqHk5sXiRFcckFPI+6uSpTjH5qXjGDCKeZRut7f LhA3c/HiG67K2AWajf5fFLLUScY/2JL6lG6M7p6bZMjfiF6xXe4wf7StVgEDNdSw 2TXuTpzfYn/7C2tPdxL9V3v3C83zWTjn2RZ5Q= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=GkCTMjFkOHx/XzF VwqMga9gusfA=; b=QEa+2TfYVLwG7fzDAbCtYqIPbbuDTQFk5SwlWA9h2u87Mj7 VeRWKrYu5zpM1Xsy1zlbNswbCnHKmx5pL2K2kjMdkXpe6gRFWzP9En2/5g5nnXhG zqTDl8CkleztBpvvqAQU5kNVak0YRPAWKVlI3B1gSdyuPKc+c394yqmC/JC0= X-Sasl-enc: PYEdoxL6AOs/I2sPTSp65ouFAo9nKBZfzTZROC/GxtGX 1476849921 Received: from [192.168.1.2] (174-21-191-61.tukw.qwest.net [174.21.191.61]) by mail.messagingengine.com (Postfix) with ESMTPA id 8E47EF29CF; Wed, 19 Oct 2016 00:05:21 -0400 (EDT) Subject: Re: pg_sample To: Charles Clavadetscher , Greg Sabino Mullane , pgsql-general@postgresql.org References: <2956c916-a8e0-36d7-20e0-499cca6b4bc6@swisspug.org> Cc: patrickbakerbr@gmail.com From: Adrian Klaver Message-ID: <3f409be2-cebf-2dc8-52dd-7f432f34c385@aklaver.com> Date: Tue, 18 Oct 2016 21:05:20 -0700 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <2956c916-a8e0-36d7-20e0-499cca6b4bc6@swisspug.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org 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 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