Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eso8A-0004d8-Tt for pgsql-general@arkaria.postgresql.org; Mon, 05 Mar 2018 11:18:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eso89-0001ZG-MM for pgsql-general@arkaria.postgresql.org; Mon, 05 Mar 2018 11:18:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eso89-0001Z5-1D for pgsql-general@lists.postgresql.org; Mon, 05 Mar 2018 11:18:09 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eso81-0006nB-Nm for pgsql-general@postgresql.org; Mon, 05 Mar 2018 11:18:08 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 838BB20AE7; Mon, 5 Mar 2018 06:17:59 -0500 (EST) Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Mon, 05 Mar 2018 06:17:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imap.cc; h= content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=Vu4z2glQyLWF3p9iyCFxWsfW+3sJsbUViM9c0NXa9AU=; b=O0sC2TMS K4T/yuXVmA9quQemXhjHhI1JCV9qLnmPmAl+1HGmlFmWll7CgAhpsrg5v4pNFgdI awynmUg7ppTBDBYLCj1BA/ktaGtXPCx69sc/dlcjfoqG4zlX6ocLYoGjG6PpB1ie LJgM4fDN/TBSji0eEtYjODv+C3xU0QCcw6VKLjgcLhxC5q2O1MKSMMEid0lGSFXm +KeE53/zveJ5p9TZ5PiqCW6jY3xqhZmT/Ba0CizL1SysOaFolAVc84OkXjtPHqQU Arb3Y1uvYRZkygLcb1uIFRIGGWdfss4cuugG1DFoP/WYzoKaJgWqaGy7+Vre2Ksd QFp5lJHN4qz6nA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=Vu4z2glQyLWF3p9iyCFxWsfW+3sJs bUViM9c0NXa9AU=; b=UjBc1XkOTZiXQLKV7Og9DGP9oyqwV7lj5deqMyNVjxYB7 RK2cXbDidA7FYVbBd9h3XCDKkP5m/LSYVECORMxNaZIDFVJEvqOiCJz14uGtW0Ff xhzvsNMBA0Rer5gUEM0A9uvCSiZk2+imYrzijotNMxITsAAXQfLDtjTwoTk2RlwS BeYDIpBI/A6sZNv18DcxPx15cAqoZilWzZHlwJYrkonzobuQA5oPrDIcrp9oC2hd 1/5TcxsitfmYUFtt7o0Z1rTOg2JG/NHw0Mfhn0rmXbBNf4QK0hYxd3uigiV67yy7 LAMuRhkr5uA9zlZTXrBJQMGTBqrmnf/Jt1NUzJftg== X-ME-Sender: Received: from [10.2.33.124] (unknown [185.25.33.73]) by mail.messagingengine.com (Postfix) with ESMTPA id F14DB7E498; Mon, 5 Mar 2018 06:17:58 -0500 (EST) Subject: Re: Incredibly slow queries on information_schema.constraint_column_usage? To: Viktor Fougstedt , "pgsql-general@postgresql.org" References: <07365773-71E4-46A4-AA10-794094DB07D6@chalmers.se> From: Alexey Bashtanov Message-ID: Date: Mon, 5 Mar 2018 11:17:55 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <07365773-71E4-46A4-AA10-794094DB07D6@chalmers.se> Content-Type: multipart/alternative; boundary="------------7374EE9448A185113BE4B936" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------7374EE9448A185113BE4B936 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Hello Viktor, There was a known slowness issue in this view. It was fixed in PG 10: https://www.postgresql.org/message-id/flat/2d533e5b-687a-09fa-a772-dac9e6cf9dd4@imap.cc#2d533e5b-687a-09fa-a772-dac9e6cf9dd4@imap.cc You can try to use a solution from there to create a faster view that returns the same data as information_schema.constraint_column_usage. I wouldn't be surprised if it was safe to replace information_schema.constraint_column_usage itself, but I cannot guarantee it. Best,   Alex --------------7374EE9448A185113BE4B936 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 8bit Hello Viktor,

There was a known slowness issue in this view.
It was fixed in PG 10: https://www.postgresql.org/message-id/flat/2d533e5b-687a-09fa-a772-dac9e6cf9dd4@imap.cc#2d533e5b-687a-09fa-a772-dac9e6cf9dd4@imap.cc
You can try to use a solution from there to create a faster view that returns the same data as information_schema.constraint_column_usage.
I wouldn't be surprised if it was safe to replace
information_schema.constraint_column_usage itself, but I cannot guarantee it.

Best,
  Alex
--------------7374EE9448A185113BE4B936--