Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Um2m3-0000cX-QZ for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Jun 2013 14:08:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Um2m3-0002dl-Ap for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Jun 2013 14:08:43 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Um2m2-0002da-LM for pgsql-bugs@postgresql.org; Mon, 10 Jun 2013 14:08:42 +0000 Received: from moutng.kundenserver.de ([212.227.17.8]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Um2lw-0005bZ-9H for pgsql-bugs@postgresql.org; Mon, 10 Jun 2013 14:08:42 +0000 Received: from anarazel.de (p5DDC60C8.dip0.t-ipconnect.de [93.220.96.200]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0MN8wu-1Ujomw32oC-006pAd; Mon, 10 Jun 2013 16:08:34 +0200 Received: by anarazel.de (Postfix, from userid 1000) id 94DEA100459; Mon, 10 Jun 2013 16:08:43 +0200 (CEST) Date: Mon, 10 Jun 2013 16:08:43 +0200 From: Andres Freund To: Gunnlaugur Thor Briem Cc: pgsql-bugs@postgresql.org Subject: Re: pg_dump is O(N) in DB table count N even if dumping only one table Message-ID: <20130610140843.GA5680@awork2.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Provags-ID: V02:K0:Cw+IO/DTjApCNU/rMUf9+Eav0Jx8kUWBElwcnNaRiuE TT4O+WsxWl/DukSj9BKt/KG6Gmta2J34RLCZJljru27eSAUzN4 CbnR+6+5rrmkGz2IQd2/v3AYZE0lLIwNOTAdm6cOgnN6NVduzr fz1Rev7dTLIMwda9wmG0k0YHIPfCkDoWXQI/JS5vTo0OKYDDie yFt0fGpLWiDIpH4EjLLSFTkiSk1M28Zh/Cz0NYAwFMhipPWZVa e2dtPLtViNWdgQsE1hnQTRLZByzl8yjDZuOwNEmgm6+/vOka1u JqEyS/ZhMdutRRiVelrVqVseOH9Wt8iTah21lbJL62J0ma/eC0 xZWDsBGWK708CKHGyiQ7N3WKa+fZXmfRup3CNo3oV X-Pg-Spam-Score: 0.8 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 2013-06-10 13:28:32 +0000, Gunnlaugur Thor Briem wrote: > Hi, > > pg_dump takes O(N) time dumping just one table (or a few) explicitly > specified with a -t parameter. It thus becomes painfully slow on a database > with very many tables. > > (The use case is copying a few tables over to a test DB, from a large > production data warehouse.) > > The three queries taking O(N) time are listed below. AFAICT each of these > queries could be filtered by table name/OID, at least when the number of > tables matching the -t parameters is small, allowing pg_dump to complete in > seconds rather than minutes. Which of those queries take how long in your case? E.g. I could imagine that the first two can be sped up a bit without changing the result. E.g. not calling pg_tablespace_location() for every relation and such. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs