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 1gMAyI-0004R5-87 for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Nov 2018 12:05:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gMAyG-0004lM-JB for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Nov 2018 12:05:36 +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 1gMAyG-0004lF-74 for pgsql-hackers@lists.postgresql.org; Mon, 12 Nov 2018 12:05:36 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gMAyC-0008TW-6d for pgsql-hackers@postgresql.org; Mon, 12 Nov 2018 12:05:34 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id C46D921C2429; Mon, 12 Nov 2018 15:05:29 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.1.10] (unknown [185.48.36.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 8BBA821C1CE2; Mon, 12 Nov 2018 15:05:29 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1542024329; bh=wzQ11NEyO33PLQ9ZfDxdGxV+ShaFVagdTOvlJFxSYXQ=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=FbO54YbX3WHAHQRwWOvbaqxTUgkov2Pg5ozIChfCbpnn/dO28Exqtck6U1ochphV2 FfqDPkpfA7wE2JfWoOjsanzxEPfjrFzQTPkyqmYJzE8LqknAfe8JE5SvdYIL/sQJFO lK/lTwbMf7K2NvOQPdRCCH4DDxML/mx3zJO7DqRE= Subject: Re: Uninterruptible long planning of a query with too many WHERE clauses To: Tom Lane Cc: PostgreSQL-development References: <90c5bdfa-d633-dabe-9889-3cf3e1acd443@postgrespro.ru> <21010.1541911093@sss.pgh.pa.us> From: Alexander Kuzmenkov Message-ID: <37b95215-b315-ecbc-0747-037ac48ad4c4@postgrespro.ru> Date: Mon, 12 Nov 2018 15:05:28 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <21010.1541911093@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk El 11/11/18 a las 07:38, Tom Lane escribió: > I think you have the right basic idea, but we don't have to completely > lobotomize the bitmap-and search logic in order to cope with this. > This code is only trying to figure out which paths are potentially > redundant, so for a path with too many quals, we can just deem it > not-redundant, as attached. Thanks for the patch, looks good to me. > A different line of thought is that using equal() to compare quals > here is likely overkill: plain old pointer equality ought to be enough, > since what we are looking for is different indexpaths derived from the > same members of the relation's baserestrictinfo list. I didn't realize that we could just hash the pointers here, this simplifies things. But indeed it makes sense to just use a simpler logic for such extreme queries, because we won't have a good plan anyway. > Another thought is that maybe we need a CHECK_FOR_INTERRUPTS call > somewhere in here; but I'm not sure where would be a good place. > I'm not excited about sticking one into classify_index_clause_usage, > but adding one up at the per-path loops would not help for this case. We added some interrupt checks as a quick fix for the client. In the long run, I think we don't have to add them, because normally, planning a query is relatively fast, and unexpected slowdowns like this one can still happen in places where we don't process interrupts. -- Alexander Kuzmenkov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company