Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gUc7B-0001Nu-S2 for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Dec 2018 18:41:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gUc7A-0006jS-2k for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Dec 2018 18:41:40 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gUc79-0006iC-NI for pgsql-hackers@lists.postgresql.org; Wed, 05 Dec 2018 18:41:39 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gUc76-0003Ye-Q4 for pgsql-hackers@postgresql.org; Wed, 05 Dec 2018 18:41:38 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id wB5IfWll008844; Wed, 5 Dec 2018 13:41:32 -0500 From: Tom Lane To: Andres Freund cc: Pavel Stehule , PostgreSQL Hackers Subject: Re: slow queries over information schema.tables In-reply-to: <20181205182555.x4wtnzffmhwsc3c7@alap3.anarazel.de> References: <5978.1544030694@sss.pgh.pa.us> <20181205175657.s7mt6as356kwvrji@alap3.anarazel.de> <8210.1544034143@sss.pgh.pa.us> <20181205182555.x4wtnzffmhwsc3c7@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Wed, 05 Dec 2018 10:25:55 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8842.1544035292.1@sss.pgh.pa.us> Date: Wed, 05 Dec 2018 13:41:32 -0500 Message-ID: <8843.1544035292@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2018-12-05 13:22:23 -0500, Tom Lane wrote: >> Not following what you have in mind here? My 0002 throws away the >> CoerceToDomain if there are *no* constraints, but I can't see any >> situation in which we'd likely be able to ignore a constraint, >> simple or not. > Yea, simple probably means nonexistant for now. We could e.g. optimize > some NOT NULL checks away, but it's probably not worth it. Ah, yes, that is a case where we might have enough knowledge to prove the test redundant --- but considering that we explicitly discourage domain NOT NULL as bad style and not fully supported, I can't get excited about it. I suppose in some cases we might be able to use predtest.c to prove domain CHECK constraints redundant, but I bet that it's not worth the trouble. The bigger picture here is that people seem to like to use domains as simple type aliases, which will never have any constraints, but we're very dumb about that today. So the patch as presented seems like it has lots of potential applicability, as long as we fix the invalidation aspect. regards, tom lane