Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 574522E0047 for ; Mon, 5 May 2008 21:56:31 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 14556-01 for ; Mon, 5 May 2008 21:56:20 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id 6E08D2E0044 for ; Mon, 5 May 2008 21:56:28 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m460uQTT005793; Mon, 5 May 2008 20:56:27 -0400 (EDT) To: Mario Weilguni cc: pgsql-performance@postgresql.org Subject: Re: Very slow INFORMATION_SCHEMA In-reply-to: <481EEFD4.3060203@sime.com> References: <481B82AE.8050607@gmail.com> <26118.1209766858@sss.pgh.pa.us> <481EEFD4.3060203@sime.com> Comments: In-reply-to Mario Weilguni message dated "Mon, 05 May 2008 13:30:28 +0200" Date: Mon, 05 May 2008 20:56:26 -0400 Message-ID: <5792.1210035386@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200805/63 X-Sequence-Number: 30031 Mario Weilguni writes: > I can confirm this for a quite larger result set (4020 rows) for a DB > with 410 tables and a lot of foreign key constraints. > ... > This is Postgresql 8.2.4, on a Dual-Core XEON 3.6GHz. With nested_loops > off, I get a very fast response (330ms). FWIW, it looks like 8.3 is significantly smarter about this example --- it's able to push the toplevel conditions on CONSTRAINT_SCHEMA and CONSTRAINT_TYPE down inside the UNION, where 8.2 fails to do so. Which is not to say that there's not more left to do on optimizing the information_schema views. In this particular case, for example, I wonder why the UNION in INFORMATION_SCHEMA.TABLE_CONSTRAINTS isn't a UNION ALL. There's probably a lot more such micro-optimizations that could be done if anyone was motivated to look at it. regards, tom lane