Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 2C83C7F9A80 for ; Thu, 29 Dec 2011 21:08:06 -0400 (AST) Received: from lo.gmane.org ([80.91.229.12]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RgQx2-0007xP-5L for pgsql-sql@postgresql.org; Fri, 30 Dec 2011 01:08:06 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RgQwp-0007pY-Hl for pgsql-sql@postgresql.org; Fri, 30 Dec 2011 02:07:51 +0100 Received: from g224121086.adsl.alicedsl.de ([92.224.121.86]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 30 Dec 2011 02:07:51 +0100 Received: from tim by g224121086.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 30 Dec 2011 02:07:51 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: pgsql-sql@postgresql.org To: pgsql-sql@postgresql.org From: Tim Landscheidt Subject: Getting a list of a table's attributes that are sortable sorted by uniqueness Date: Fri, 30 Dec 2011 01:07:39 +0000 Organization: Lines: 18 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: g224121086.adsl.alicedsl.de Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:+Khx0pT0u/Q5k2BHq1UUbr3n86w= X-Pg-Spam-Score: -5.5 (-----) X-Archive-Number: 201112/88 X-Sequence-Number: 36149 Hi, I frequently use pg_dump to dump databases and compare them with diff. To get rid of most "false positives", I'd like to patch pg_dump to sort the table so that its dumped order isn't changed more than necessary by insertions & Co. So I'm looking for a query that will return a list of a table's attributes that are sortable (e. g. no XML fields) and sorted by "uniqueness", i. e. first attributes repre- senting the primary key, then other unique keys, then the rest. Before I dive into the depths of PostgreSQL's system cata- logues, has anyone already solved this problem? TIA, Tim