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 1rIUgr-008xbU-Br for pgsql-performance@arkaria.postgresql.org; Wed, 27 Dec 2023 14:15:21 +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 1rIUgp-006DuX-VJ for pgsql-performance@arkaria.postgresql.org; Wed, 27 Dec 2023 14:15:19 +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 1rIUgp-006DuP-KL for pgsql-performance@lists.postgresql.org; Wed, 27 Dec 2023 14:15:19 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rIUgl-00E9iO-RW for pgsql-performance@postgresql.org; Wed, 27 Dec 2023 14:15:18 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-a2330a92ae6so587541366b.0 for ; Wed, 27 Dec 2023 06:15:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1703686514; x=1704291314; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=72tYuvFaJRqFv/MtUMug1F4geaNXdroXTsaeGeiJgsA=; b=WiWgutEGPB0uJNBATeeDncJnrmq7dmJktxNR+Zlvr/OvRa+tIjyzkWCA6ht8fUaw0+ ryEf70Psnm3gWpr7hUsWcXAIgFxPZvi2jSELTt4XyRKeuej1cjIegl9UT3JxG3opYM01 JRYlT4ONZ0ZErazAfsJvb/KwcE+yhISRVbYveF+zkJZocu732yjB9Ik5DmIGGg4zEZpF Mp6h/xjAG4rYEkkXkpKjEbk1gM/4WKiMSYNGuKz1VJ+SIS9efcSFUU2XXchEOg0797j1 4TpcQfyeSYCpBzTOvcFCcCAup3uE3JCMEmyWtMpikYUxMNiXw51qpmBXuSC995OaTqwB D95A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703686514; x=1704291314; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=72tYuvFaJRqFv/MtUMug1F4geaNXdroXTsaeGeiJgsA=; b=Uc+Q9qSFGjlumytPK0P12d41dCGf+G7IvZLtUEz97+v95jtdQ8+6+/f8o+V9ZDPl9a 0B7aUtEwBVxiML/bBSR8NIVVBSiHka2LX0zNKBATGrosfyvpLBzhPgDvo10iH8AG//4m wsQI+l253oHncTBoZW/ZTO98rlOczyybvtSa51SJUy+FIsABAX9Hps0ty2I6w3RF74u/ eOzEwhOrt8rxJgFtb4JdHR8lXURa3cYvpyQHTsObknXO3AP8qFIH5+g5aOeaEpVp38Wg JgnCQEairjfblGufrcIyIAhQL7JkPL81DB7Mt8ymId+lM/yDfwmSpBc7FJfHKaUj12MS nt4A== X-Gm-Message-State: AOJu0YynkmD/BVNE0bCaDh+lJsStAQQqiFyb4r0tbWWUEG0WTCrl1nca BflFTHEdJYpf/KOcCY6tYfIeksbsmZ2f X-Google-Smtp-Source: AGHT+IGcELgCfw3j8Rp7zjRDNsFvYQ71qKG4A8wh9H/pxeXp38IMLMEV84TLx9FfIJ7X4/VvOVAiXw== X-Received: by 2002:a17:906:9889:b0:a26:f057:974 with SMTP id zc9-20020a170906988900b00a26f0570974mr1765770ejb.152.1703686514108; Wed, 27 Dec 2023 06:15:14 -0800 (PST) Received: from [10.137.0.17] (ip-86-49-229-30.bb.vodafone.cz. [86.49.229.30]) by smtp.gmail.com with ESMTPSA id oq2-20020a170906cc8200b00a26f63d16f6sm2417961ejb.25.2023.12.27.06.15.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Dec 2023 06:15:13 -0800 (PST) Message-ID: <5ecd893b-be4c-72ea-4896-e0f9afcf33d3@enterprisedb.com> Date: Wed, 27 Dec 2023 15:15:11 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: Parallel hints in PostgreSQL with consistent perfromance To: mohini mane , pgsql-performance@postgresql.org References: Content-Language: en-US From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/27/23 14:15, mohini mane wrote: > Hello Team, > I observed that increasing the degree of parallel hint* *in the SELECT > query did not show performance improvements. > Below are the details of sample execution with EXPLAIN ANALYZE > *PostgreSQL Version:* v15.5 > > *Operating System details:* RHL 7.x > Architecture:          x86_64 > CPU op-mode(s):        32-bit, 64-bit > Byte Order:            Little Endian > CPU(s):                16 > On-line CPU(s) list:   0-15 > Thread(s) per core:    1 > Core(s) per socket:    16 > Socket(s):             1 > NUMA node(s):          1 > Vendor ID:             GenuineIntel > CPU family:            6 > Model:                 79 > Model name:            Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz > Stepping:              1 > CPU MHz:               2294.684 > BogoMIPS:              4589.36 > Hypervisor vendor:     Microsoft > Virtualization type:   full > L1d cache:             32K > L1i cache:             32K > L2 cache:              256K > L3 cache:              51200K > NUMA node0 CPU(s):     0-15 > > *PostgreSQL Query:*  > Sample sql executed through psql command prompt > force_parallel_mode=on; max_parallel_workers_per_gather=200; > max_parallel_workers=6 > > explain analyze select /*+ PARALLEL(A 6) */ ctid::varchar, >  md5("col1"||'~'||"col7"||'~'||"col9"::varchar) , > md5("id"||'~'||"gender"||'~'||"firstname"||'~'||"lastname"||'~'||"address"||'~'||"city"||'~'||"salary"||'~'||"pincode"||'~'||"sales"||'~'||"phone"||'~'||"amount"||'~'||"dob"||'~'||"starttime"||'~'||"timezone"||'~'||"status"||'~'||"timenow"||'~'||"timelater"||'~'||"col2"||'~'||"col3"||'~'||"col4"||'~'||"col5"||'~'||"col6"||'~'||"col8"||'~'||"col10"||'~'||"col11"||'~'||"col12"||'~'||"col13"||'~'||"col14"||'~'||"col15"||'~'||"col16"||'~'||"col17"::varchar) ,  md5('@'||"col1"||'~'||"col7"||'~'||"col9"::varchar)  from "sp_qarun"."basic2" A  order by 2,4,3; > Postgres doesn't support hints, so the /* ... */ part of the query is just a comment and doesn't effect the parallelism at all. The main thing influencing that are the GUC values you set before. > *Output:* > PSQL query execution with hints 6 for 1st time => 203505.402 ms > PSQL query execution with hints 6 for 2nd time => 27920.272 ms > PSQL query execution with hints 6 for 3rd time => 27666.770 ms > Only 6 workers launched, and there is no reduction in execution time > even after increasing the degree of parallel hints in select query. > It's unclear if what exactly you changed, and what case you're comparing the timing to. As I explained earlier, the hint comment has no effect. So if that's what you increased, it's not surprising the timing does not change. Also, max_parallel_workers is the maximum total number of parallel workers, i.e. it's upper bound of max_parallel_workers_per_gather. So if you set it to 6, there will never be more than 6 workers, no matter what value max_parallel_workers_per_gather is set to. FWIW force_parallel_more is really meant for testing (in the context of developing the database itself), it's hardly the thing you should do in any other case, like for example testing performance. > *Table Structure:* > create table basic2(id int,gender char,firstname varchar(3000), > lastname varchar(3000),address varchar(3000),city varchar(900),salary > smallint, > pincode bigint,sales numeric,phone real,amount double precision, > dob date,starttime timestamp,timezone TIMESTAMP WITH TIME ZONE, > status boolean,timenow time,timelater TIME WITH TIME ZONE,col1 int, > col2 char,col3 varchar(3000),col4 varchar(3000),col5 varchar(3000), > col6 varchar(900),col7 smallint,col8 bigint,col9 numeric,col10 real, > col11 double precision,col12 date,col13 timestamp,col14 TIMESTAMP WITH > TIME ZONE, > col15 boolean,col16 time,col17 TIME WITH TIME ZONE,primary > key(col1,col7,col9));  > > *Table Data:* 1000000 rows with each Row has a size of 20000. > Without the data we can't actually try running the query. In general it's a good idea to show the "explain analyze" output for the cases you're comparing. Not only that shows what the database is doing, it also shows timings for different parts of the query, how many workers were planned / actually started etc. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company