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 1ooLZf-0000yv-DU for pgsql-bugs@arkaria.postgresql.org; Fri, 28 Oct 2022 09:22:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ooLZe-0001aL-7x for pgsql-bugs@arkaria.postgresql.org; Fri, 28 Oct 2022 09:22:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ooK0X-0003Nl-GZ for pgsql-bugs@lists.postgresql.org; Fri, 28 Oct 2022 07:42:25 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ooK0U-00028J-Nl for pgsql-bugs@lists.postgresql.org; Fri, 28 Oct 2022 07:42:24 +0000 Received: by mail-pj1-x102d.google.com with SMTP id m14-20020a17090a3f8e00b00212dab39bcdso9180950pjc.0 for ; Fri, 28 Oct 2022 00:42:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dataegret-com.20210112.gappssmtp.com; s=20210112; h=content-language:content-transfer-encoding:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject:from:to:cc :subject:date:message-id:reply-to; bh=5QWeYsvDEdwRq1fTrSoJrqVU5g3ueOEcBzgiKcMqneU=; b=T0Wl1f+0+Yyi2CrRtKF9Lf9VsOX40NdQhTjPhj0IzhN1I2OzvKsRGz+kVdOxcoVqOj KxUgBpQABoJZGMC/fZNJGxMSu5BNBSNNdUI7RiN7GBnD3/mW+SaqmW0T4olDxf77Ll62 AaISssaoRZBD/Qz4zjGpo08yH1QLMXGXScU6w2IDJGZzwxpLnOjySGw3hkWAMl52Yvjg Ts9GrXgXhX5wt8UEtd1/cezcfuzXn2pz70xKdSNkTYe15LIq6dF2CyxUgefElPZSCDkI o87XPEOqFFzlMpL5O5cGsqfgAlpv0fPpwDQrfobgBt+ibh/fiIuJ98derOU1bspz4jvJ EHtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-language:content-transfer-encoding:in-reply-to:mime-version :user-agent:date:message-id:from:references:cc:to:subject :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5QWeYsvDEdwRq1fTrSoJrqVU5g3ueOEcBzgiKcMqneU=; b=gzK44xHw3dQrnRjkiOq92yAIrhcahA8an6rHXyzXDlNTv4geX8hTThmnL4F2nFI08K lXpnek6rWKChMz91a6mai7XZCzw1bYEKnr/h4IsB9QZZJGvmqlo4ReyJseDc1lBodRSQ HpOyryWx8XyAkX7uQA4N7OgCM5ovbrQ17qRwLI2jygB6HAh7dB9IhGEQQvyPMyfl+3ge nFBvsovqx1uTb5fgMhD6zl9K9iXt6kUU0ha6N+K0Bunl9gzyNXRRkEiTZcJBKUYIHFTA kwQJ2kswp9tRG5tyDQgths/UuxGZG60FipBPFggz/sxOTXUzptZcQBNN+tG9dxkmfGXY s9pg== X-Gm-Message-State: ACrzQf2jgpJik07CX7pvolNPCwkN37ddJv4UQ2fOl66ngdqODuYzFRf6 jk1eb1nlUuzqPdLW6JhYn9vSTvbMZwDvlw== X-Google-Smtp-Source: AMsMyM6vUwVcS+DS1r3UVNztzFuChcTi/RU8rJbHyXrM2KpoQCJMGRzGD7o5V86Siz7pmMzklNMwGw== X-Received: by 2002:a17:90a:c306:b0:211:8e5e:9a66 with SMTP id g6-20020a17090ac30600b002118e5e9a66mr15251695pjt.152.1666942940925; Fri, 28 Oct 2022 00:42:20 -0700 (PDT) Received: from iMac.local ([62.118.85.75]) by smtp.googlemail.com with ESMTPSA id d67-20020a621d46000000b0056164b52bd8sm2297153pfd.32.2022.10.28.00.42.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Oct 2022 00:42:20 -0700 (PDT) Subject: Re: BUG #17668: Query normalization generates multiple queryId:s for calls to the same procedure To: Tom Lane , Julien Rouhaud Cc: marcus.kempe@gmail.com, pgsql-bugs@lists.postgresql.org References: <17668-e25abc1f5375b095@postgresql.org> <20221027160834.uxhmt473grlpfv5x@jrouhaud> <748392.1666895297@sss.pgh.pa.us> From: Alexey Ermakov Message-ID: <06ff22d7-e92a-f97b-8b91-512de71aea9f@dataegret.com> Date: Fri, 28 Oct 2022 13:42:10 +0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <748392.1666895297@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, I've seen possibly related case where that might be a problem. PostgreSQL 12.8, pg_stat_statements.max=10000. There are queries like these: insert into tablename (col1, ..., col28) values ($1, ..., $28), ... ($2605, ... , $2660) on conflict do nothing. Problem is that not only we might insert different number of rows but there might be many duplicates of the same exact query in pg_stat_statements (userid and dbid are the same in all rows): select md5(query), count(*), pg_size_pretty(sum(length(query))) from pg_stat_statements where query like 'insert into tablename%' group by 1 order by 2 desc limit 10;    md5    | count | pg_size_pretty ----------+-------+----------------  170...84 |  1283 | 2679 kB  906...53 |   897 | 1724 kB  55e...78 |   676 | 12 MB  ea4...ef |   642 | 11 MB  944...0f |   629 | 11 MB  04e...ec |   530 | 9138 kB  572...27 |   476 | 8575 kB  5ea...3c |   430 | 7331 kB  be1...6c |   324 | 5704 kB  f69...47 |   313 | 550 kB There are 8 bigint columns in the table, I suspect that we might insert into some of them values both greater and less than INT_MAX. In result pg_stat_statements buffer is full of such queries (they take 9k rows out of 10k right now, 10h since pg_stat_statements_reset call), currently total sum of query lengths is 117MB (97% of total sum). From monitoring perspective that might be a problem since calculating metrics from pg_stat_statements became more expensive and we might lose information about some queries when there is not enough space for them. But I suppose such cases are pretty rare and some of them could be fixed with COPY queries instead of inserts. -- Thanks, Alexey Ermakov On 2022-10-28 00:28, Tom Lane wrote: > Julien Rouhaud writes: >> On Thu, Oct 27, 2022 at 01:49:18PM +0000, PG Bug reporting form wrote: >>> I would have expected both calls to be normalized and fingerprinted to one >>> and the same queryId. >> Agreed, and that's actually a known problem that is currently being worked on. >> You can look at >> https://www.postgresql.org/message-id/flat/36e5bffe-e989-194f-85c8-06e7bc88e6f7%40amazon.com >> for details about the discussion and in-progress fix. > Um ... that seems unrelated. AFAICS the OP is complaining about > the fact that '42'::int4::int8 is not identical to '42'::int8. > Well, they're not. I seriously doubt that we would or should > consider trying to get queryjumble to mask that. > > regards, tom lane > >