Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s8PHw-00CNmp-F8 for pgsql-hackers@arkaria.postgresql.org; Sat, 18 May 2024 19:00:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s8PHv-009WD1-NE for pgsql-hackers@arkaria.postgresql.org; Sat, 18 May 2024 19:00:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1s8PHv-009WCt-D9 for pgsql-hackers@lists.postgresql.org; Sat, 18 May 2024 19:00:11 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s8PHn-000uw8-8U for pgsql-hackers@postgresql.org; Sat, 18 May 2024 19:00:10 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-51f0b6b682fso3356603e87.1 for ; Sat, 18 May 2024 12:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716058802; x=1716663602; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=i2vkQNibpTh8kOwISuv94BJhJR+r29CcH8OE8/1wsOo=; b=abqTd3mCm0uIDPLsMNUjuqBuKBt5vBfAi3B/bdgtnMrfb4hao+hl5EVawV1ga9kbcJ 8Y4dnPIBRPxbQZ3svESMAjlXs9zwxneimy/kshvqVO9nvXu5glrvY559bYa3FdtujsGX /g9sHf2gb5YJJrLVwUCOGda0VsKc8eSpK7/VPfvhegN32+7uFn4CBkQ6XIdhEDIREpKf a3bWrppYjRrR8ohAOD5LcigngKbCYlG0qFeY3Sw4xDpenIuIJREGvJqhfiRWQEE93KDQ RJbolyMrCro9Scve8gPMeOb+8ivJYa+0/2goDosVbv50K/vybkOebunsxyKH8iJ1pyPg R56A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716058802; x=1716663602; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=i2vkQNibpTh8kOwISuv94BJhJR+r29CcH8OE8/1wsOo=; b=kNxAfv9cbWCcY+iiRJBzwkfCZOGpC4oUkNzXVOCRGoK2lfCS+F25FmOgM+44JWJEdp LHhmyZRsr25Cv/ON2cC/IQf3WWA5xcaWz5YJa/O5mabhLvNffblDrut/EMCRZwPDd/DL QI1isp4kzM8aAtQ01kvVJCeuo/UUQnycSmMsxxNN2V44TrixaO8UdzPfftHOBb3oU8vx 73wryjuM5s8EM5XNvjziFiXzDdRVXFyXHvBFsfiH+NQW/cSZXS40sylQ/rNsF2YZJ2l7 P3W6VgRvIZ7mMCo34kLMQwOVTpDRjzvUY/x8ln6+TR8sMfmsHp7Q1DDCAmcsuwINeR45 O1hg== X-Forwarded-Encrypted: i=1; AJvYcCVw9uR/1l8ebvRmUKc0HeDu1dpTwJkFWsaaeF0CavmO0CsOwOCnObxWcIq+na8CJMqE6c9ok/yfDNRWHQc4K3zYTiYZHAesbHN+DdgP X-Gm-Message-State: AOJu0YxmO9W1cefk4Pkz+OxzmDoU9EKUbe6ZN2paTY8l9ChKqaZERQfO F0B0+h5QhZdsfICARh37Cf2FPvYCYepN3ogQY/q50xwqrVZegx33 X-Google-Smtp-Source: AGHT+IFJ3JVSaEUWwUtHV5ri3gZkEtIjMpbcXV+TSSLrl+OKsM2N3AE+0lXCaj1ecsG8N8IaW4cAtg== X-Received: by 2002:a05:6512:33c6:b0:51d:9ef1:7c62 with SMTP id 2adb3069b0e04-5220fc6df57mr28339070e87.6.1716058801855; Sat, 18 May 2024 12:00:01 -0700 (PDT) Received: from [1.0.0.7] ([178.155.16.152]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5237a08f3e9sm1626547e87.78.2024.05.18.12.00.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 18 May 2024 12:00:01 -0700 (PDT) Message-ID: Date: Sat, 18 May 2024 22:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: Streaming read-ready sequential scan code Content-Language: en-US To: Thomas Munro Cc: Andres Freund , Melanie Plageman , David Rowley , Heikki Linnakangas , Pg Hackers References: <20240407221229.upgvhyf2gzflcawi@awork3.anarazel.de> <63a63690-dd92-c809-0b47-af05459e95d1@gmail.com> From: Alexander Lakhin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello Thomas, 18.05.2024 07:47, Thomas Munro wrote: > After more debugging, we learned a lot more things... > > 1. That query produces spectacularly bad estimates, so we finish up > having to increase the number of buckets in a parallel hash join many > times. That is quite interesting, but unrelated to new code. > 2. Parallel hash join is quite slow at negotiating an increase in the > number of hash bucket, if all of the input tuples are being filtered > out by quals, because of the choice of where workers check for > PHJ_GROWTH_NEED_MORE_BUCKETS. That could be improved quite easily I > think. I have put that on my todo list 'cause that's also my code, > but it's not a new issue it's just one that is now highlighted... > 3. This bit of read_stream.c is exacerbating unfairness in the > underlying scan, so that 1 and 2 come together and produce a nasty > slowdown, which goes away if you change it like so: > > - BlockNumber blocknums[16]; > + BlockNumber blocknums[1]; > > I will follow up after some more study. Thank you for the information! Unfortunately, I can't see significant differences in my environment with parallel_leader_participation=off. With blocknums[1], timing is changed, but the effect is not persistent. 10 query15 executions in a row, b7b0f3f27: 277.932 ms 281.805 ms 278.335 ms 281.565 ms 284.167 ms 283.171 ms 281.165 ms 281.615 ms 285.394 ms 277.301 ms b7b0f3f27~1: 159.789 ms 165.407 ms 160.893 ms 159.343 ms 160.936 ms 161.577 ms 161.637 ms 163.421 ms 163.143 ms 167.109 ms b7b0f3f27 + blocknums[1]: 164.133 ms 280.920 ms 160.748 ms 163.182 ms 161.709 ms 161.998 ms 161.239 ms 276.256 ms 161.601 ms 160.384 ms I placed PGDATA on tmpfs to rule out any blockdev specifics (increasing blockdev ra from 256 to 4096 didn't help me with PGDATA on NVME either.) Best regards, Alexander