Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nTm8o-0004nI-1b for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Mar 2022 14:57:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nTm8m-0006ct-Sa for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Mar 2022 14:57:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1nTm8m-0006cW-H6 for pgsql-hackers@lists.postgresql.org; Mon, 14 Mar 2022 14:57:44 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1nTm8k-0002Pz-EP for pgsql-hackers@postgresql.org; Mon, 14 Mar 2022 14:57:44 +0000 Received: by mail-ej1-x629.google.com with SMTP id hw13so33420076ejc.9 for ; Mon, 14 Mar 2022 07:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=HQRhTTw7Hoixva4Tiz+tWdJxcRbkuvpGw1yDKbZsT8s=; b=pNSHkAllvB3lBTOBtHTQn+hVmbtboIH6WT0/aM3ddWC62g8MQjywv4J8sG0pqcU+nm fn8DcPbA7isP7gLV7IaJmB/N4H1A/blp4BjfYuTc5HRg3uCfNWvthnDtznHdfmGm/OCS 2vbYv8pl90GQL+YIJvXucYKy6rUA8PHplL5f5RStbFLAtc+yGzjr3oX/e2plHj0YJ2VL D8VD/ccF/L6ztt+PykBF9hhiBXfLeAXZ2BAUUfKoncevjtTQLJKsCsCTZFonyfKF6XVB plvykQoJZ4JOIGGZqn2PSkm8jiDh33MyfK8uUNwfICXuK0E6No+5iAN5FSszw6g8hQYQ R4ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HQRhTTw7Hoixva4Tiz+tWdJxcRbkuvpGw1yDKbZsT8s=; b=xEeEOJwMmwtnPRXeirqfzXI4ebBw26Dd39kKu0KS/7jrB67jLdrFX4OQtQjZHaWIdP ueRPnPZuB5TAAylMUnVlMA4ltDHOPQeJHTLCn8sDht+/2juzJawjSdkLlURvgOXeb3dK yt80qfJbBxo0UXpYBCgmrZGGUhfacdySby9rKDc6B5xuXzZiZHZC5gL/No2T2uqh8o6f 5OscE46pwdeKJ+g7tyDBIw7fpF384nEbsKF08sSbpZgMCvus8LIrUrK6p2hm4y/720sM w5m7u/mciU1l3x0Gv12YQD3xi9dbRWO7+cBuxkHBovTfbaHDu7oE8Zb1jhGU8FEWQIPK H3bQ== X-Gm-Message-State: AOAM533k755a3rPg+v17zL0FcQlepzPE/fR5ekKkjMMSlAcr6WGEvH1Y KJWVDjHmprna0rWwTsgeZ8s= X-Google-Smtp-Source: ABdhPJwqSZRpdRxdqELdsBkOlLbLaGwsWu6Dgxt6F01uZ5WepaXANz9LQKcJaKp+ZE1389SGT+SU3w== X-Received: by 2002:a17:907:3f17:b0:6da:68b6:7876 with SMTP id hq23-20020a1709073f1700b006da68b67876mr19011523ejc.740.1647269856596; Mon, 14 Mar 2022 07:57:36 -0700 (PDT) Received: from ddolgov.remote.csb (dslb-094-222-030-091.094.222.pools.vodafone-ip.de. [94.222.30.91]) by smtp.gmail.com with ESMTPSA id f6-20020a0564021e8600b00412ae7fda95sm8205724edf.44.2022.03.14.07.57.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Mar 2022 07:57:36 -0700 (PDT) Date: Mon, 14 Mar 2022 15:57:34 +0100 From: Dmitry Dolgov <9erthalion6@gmail.com> To: Robert Haas Cc: Tom Lane , Zhihong Yu , David Steele , PostgreSQL-development , Greg Stark , Pavel Trukhanov Subject: Re: pg_stat_statements and "IN" conditions Message-ID: <20220314145734.x3re4hcr6ukmppwi@ddolgov.remote.csb> References: <20210616140212.kt3n5wi3alfz5i5d@localhost> <20210930134930.d4vzwhvxhfpk2zxt@localhost> <20210930150957.tz3h3unjyrzatw6e@localhost> <4154685.1641337363@sss.pgh.pa.us> <20220105211111.5oh7ypjfonaqubuq@erthalion.local> <20220310163837.pzvr4yntdk33cbkb@ddolgov.remote.csb> <655954.1646932319@sss.pgh.pa.us> <20220312141030.5panohzsskr4zpkk@erthalion.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Mon, Mar 14, 2022 at 10:17:57AM -0400, Robert Haas wrote: > On Sat, Mar 12, 2022 at 9:11 AM Dmitry Dolgov <9erthalion6@gmail.com> wrote: > > Here is the limited version of list collapsing functionality, which > > doesn't utilize eval_const_expressions and ignores most of the stuff > > except ArrayExprs. Any thoughts/more suggestions? > > The proposed commit message says this commit intends to "Make Consts > contribute nothing to the jumble hash if they're part of a series and > at position further that specified threshold." I'm not sure whether > that's what the patch actually implements because I can't immediately > understand the new logic you've added, but I think if we did what that > sentence said then, supposing the threshold is set to 1, it would > result in producing the same hash for "x in (1,2)" that we do for "x > in (1,3)" but a different hash for "x in (2,3)" which does not sound > like what we want. What I would have thought we'd do is: if the list > is all constants and long enough to satisfy the threshold then nothing > in the list gets jumbled. Well, yeah, the commit message is somewhat clumsy in this regard. It works almost in the way you've described, except if the list is all constants and long enough to satisfy the threshold then *first N elements (where N == threshold) will be jumbled -- to leave at least some traces of it in pgss. > I'm a little surprised that there's not more context-awareness in this > code. It seems that it applies to every ArrayExpr found in the query, > which I think would extend to cases beyond something = IN(whatever). > In particular, any use of ARRAY[] in the query would be impacted. Now, > the comments seem to imply that's pretty intentional, but from the > user's point of view, WHERE x in (1,3) and x = any(array[1,3]) are two > different things. If anything like this is to be adopted, we certainly > need to be precise about exactly what it is doing and which cases are > covered. I'm not sure if I follow the last point. WHERE x in (1,3) and x = any(array[1,3]) are two different things for sure, but in which way are they going to be mixed together because of this change? My goal was to make only the following transformation, without leaving any uncertainty: WHERE x in (1, 2, 3, 4, 5) -> WHERE x in (1, 2, ...) WHERE x = any(array[1, 2, 3, 4, 5]) -> WHERE x = any(array[1, 2, ...]) > I thought of looking at the documentation to see whether you'd tried > to clarify this there, and found that you hadn't written any. > > In short, I think this patch is not really very close to being in > committable shape even if nobody were objecting to the concept. Sure, I'll add documentation. To be honest I'm not targeting PG15 with this, just want to make some progress. Thanks for the feedback, I'm glad to see it coming!