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 1oZQS1-0001Sf-D7 for pgsql-performance@arkaria.postgresql.org; Sat, 17 Sep 2022 05:33:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oZQS0-0007Nn-9R for pgsql-performance@arkaria.postgresql.org; Sat, 17 Sep 2022 05:33:12 +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 ) id 1oZQRz-0007Ne-SF for pgsql-performance@lists.postgresql.org; Sat, 17 Sep 2022 05:33:11 +0000 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oZQRt-0001GF-M0 for pgsql-performance@lists.postgresql.org; Sat, 17 Sep 2022 05:33:11 +0000 Received: by mail-ed1-x531.google.com with SMTP id x94so16959186ede.11 for ; Fri, 16 Sep 2022 22:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date; bh=7QnKc1aDlCfPfPWCihKmNVa7+wE3xZMNqv4sf76B8J8=; b=h7xuJsX++95IT8wMJxx8cBPOGfJQOtWMcFssMT7X62lq6+X+Z93oLa7YkgnTSZJvp9 e9aERLvJ6dX6zFvW/B3dMQKJqEMoZnnP+eFslzgQ9M1Hku3wMgL9+A7FCBA+R36+ReBP hf2U4WauxCsP0FU8Cb53Qs0NZj0cBMFx/hLqioDxojQhxiCZA2Ccb+xE5HK+GIF6Q3Lo NHf3URvKMisc7kETvvTX9T3yEq46jRccFK1D0YlRH7DKxACv7EUzFtQPeuGEUFj0f7Gq pBcq4uAF/Fom7gOcWUIquixp6UBO4xmx95JVhmvD+IPd9YWgODEr3EKIYjz9szb8PTMY jLQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date; bh=7QnKc1aDlCfPfPWCihKmNVa7+wE3xZMNqv4sf76B8J8=; b=hoplhjKfYtEyNtcymHAav/C3KOHYJd3Bwa4U87BfwVSLGdjmL5N8PspNQPbvJItXdh OOXz00DTwLG/X2MQnqzZOK55nmdUHhSHklXPQHI3eBVBi1+a9JrCFFa73+6dBa/dsnho XBSPjcEh7YPdztLwQfDg10Q9Drw5YumcVOwm9KJ7GI5WsDYHe/lw3hNDRHBLYM2Y84Sj N4yVcKvqy8O7Xe51imoUDWFHGj3synKEYe3MqZf7CahQxU1N5XMF81+wFQCaBxevmFnX 5vB+zzya/BSCxXzE4i73BWloSWZWAMuWn4k8ZC7SZxEntAlwTE93uuNaHlqhOv3Y2D0Y /kYg== X-Gm-Message-State: ACrzQf2WSbT7X+Ft8niV5GYMSoDArCHyRxlFDosffC9hoUoGilE6mt3l xgKTRb2EkhCOybHHeCQuQKkR5ufrcfN4kQ== X-Google-Smtp-Source: AMsMyM67iIvoBh0S7wLCCXRSX0BgRVXfmdFbP6Wvq5l9h9n8ubhsce84v/4dP7cAPfTgJ1mPgXf0Kg== X-Received: by 2002:a05:6402:2947:b0:451:32a:2222 with SMTP id ed7-20020a056402294700b00451032a2222mr6535562edb.376.1663392784576; Fri, 16 Sep 2022 22:33:04 -0700 (PDT) Received: from localhost.localdomain (91-115-147-236.adsl.highway.telekom.at. [91.115.147.236]) by smtp.gmail.com with ESMTPSA id p26-20020a17090653da00b00779a605c777sm11557107ejo.192.2022.09.16.22.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 22:33:04 -0700 (PDT) Message-ID: Subject: Re: Milions of views - performance, stability From: Laurenz Albe To: Hubert Rutkowski , pgsql-performance@lists.postgresql.org Date: Sat, 17 Sep 2022 07:33:03 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 2022-09-17 at 01:05 +0200, Hubert Rutkowski wrote: > Hello! I have written python program to benchmark view efficiency, because in our platform > they have a role to play and we noticed the performance is less than expected. If your platform plans to use millions of views, you should revise your design. As you see, that is not going to fly. And no, I don't consider that a bug. > Basically, benchmark creates table: > > CREATE TABLE IF NOT EXISTS foobar ( id int, text varchar(40) ); > > for i in range(1200300): >     INSERT INTO foobar (id, text) VALUES ({i}, 'some string'); >     CREATE VIEW foobar_{i} as select * from foobar where id={i}; > > Couldn't be any simpler. > [general slowness] > > What's even stranger is dropping performance: DROP TABLE foobar CASCADE;. First of all, had to > increase locks to allow it to finish, otherwise it was quickly bailing because of "too little shared memory". >     alter system set max_locks_per_transaction=40000; > > But even after that, it took almost 7 hours and crashed: > > 2022-09-13 23:16:31.113 UTC [1] LOG: server process (PID 404) was terminated by signal 9: Killed > > After updating Postgres to 14.5, it crashed in a bit different way: > > 2022-09-15 19:20:26.000 UTC [67] LOG: checkpoints are occurring too frequently (23 seconds apart) > 2022-09-15 19:20:26.000 UTC [67] HINT: Consider increasing the configuration parameter "max_wal_size". > 2022-09-15 19:20:39.058 UTC [1] LOG: server process (PID 223) was terminated by signal 9: Killed > 2022-09-15 19:20:39.058 UTC [1] DETAIL:  Failed process was running: drop table foobar cascade; > > Wihout the views, table can be dropped in 20ms. You misconfigured your operating system and didn't disable memory overcommit, so you got killed by the OOM killer. Basically, the operation ran out of memory. Yours, Laurenz Albe