Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hr0z2-0000SO-0r for pgsql-general@arkaria.postgresql.org; Fri, 26 Jul 2019 14:14:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hr0z0-0001m7-TL for pgsql-general@arkaria.postgresql.org; Fri, 26 Jul 2019 14:14:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hr0z0-0001lz-2y for pgsql-general@lists.postgresql.org; Fri, 26 Jul 2019 14:14:06 +0000 Received: from dragonfly.birch.relay.mailchannels.net ([23.83.209.51]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1hr0yw-0000N0-CE for pgsql-general@lists.postgresql.org; Fri, 26 Jul 2019 14:14:04 +0000 X-Sender-Id: dreamhost|x-authsender|03s_mobile@tclish.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id E2E35342A4D; Fri, 26 Jul 2019 14:13:59 +0000 (UTC) Received: from pdx1-sub0-mail-a42.g.dreamhost.com (100-96-38-36.trex.outbound.svc.cluster.local [100.96.38.36]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 10C82342937; Fri, 26 Jul 2019 14:13:59 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|03s_mobile@tclish.org Received: from pdx1-sub0-mail-a42.g.dreamhost.com ([TEMPUNAVAIL]. [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.17.3); Fri, 26 Jul 2019 14:13:59 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|03s_mobile@tclish.org X-MailChannels-Auth-Id: dreamhost X-Trouble-Descriptive: 011efe7969597a28_1564150439453_1218406373 X-MC-Loop-Signature: 1564150439452:217340203 X-MC-Ingress-Time: 1564150439452 Received: from pdx1-sub0-mail-a42.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a42.g.dreamhost.com (Postfix) with ESMTP id C4E1F851F6; Fri, 26 Jul 2019 07:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=03s.net; h=subject:to :references:from:message-id:date:mime-version:in-reply-to :content-type:content-transfer-encoding; s=03s.net; bh=vBi7Wq0yp x9zzeTo6RM0nJdfTXQ=; b=Yn4ITFWUEzB8VaAhnwlwfJsL7GzFFxTVSYcuMujSl sJ6CCG29/oB2SUD5caeqc/PFBlYD0EL6MGD2paH4T78QgPsiiSOe9MKmWrXrtAzg Mj+3w1RtPKsRFB3hJroodDDhsY8ikKmupK/E2EPeKqzn/L6kI1mn81t368+PXVJF 3w= Received: from [192.168.99.32] (unknown [27.104.210.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: 03s_mobile@tclish.org) by pdx1-sub0-mail-a42.g.dreamhost.com (Postfix) with ESMTPSA id 5E24E803D5; Fri, 26 Jul 2019 07:13:52 -0700 (PDT) Subject: Re: Running concurrent txns and measuring the timings in Postgres To: pgsql-general@lists.postgresql.org References: <160cb824-6952-d468-9a6b-3b7474348d5a@aklaver.com> <77a9686c-4d6d-e964-019f-1966224ae803@aklaver.com> X-DH-BACKEND: pdx1-sub0-mail-a42 From: Adrian Ho Openpgp: preference=signencrypt Autocrypt: addr=ml+postgresql@03s.net; prefer-encrypt=mutual; keydata= mQENBFbQLAIBCAC3GoB1MI5u7ZgGhdcgDgoPPfqiJH+sLKRazC0UihiQMX6Q1RV/LfsRhJOf EviBN2kO+ZpcK36erKfwPOO80COw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NkMhd9KvCEfSFSV6UIcnhOyF/JFABEBAAGJAR8EGAEIAAkFAlbQLAICGwwA CgkQ1IJC15L2CgMZJgf/empaVO/K0pcnZveJAw3hHmi+9uzKW+f1Qd3jtBC7E94UV8Bqx088 P+ZEwnuMIszB4fkNYbX9hdZC22MuZU1rP58G0ccoOm4kVW+tFlxzM4PHOpdGMsDv0xA7HF4+ RUVppuB9xesbb+DgTtwze1mHkn0j8fr/QsiaWOx/XB7RMy6eEc3dI672kKZLPOtJEv8iNCoz 06GCCyYC2LXxWEtvaNzO4a+xYtj5EVe0Lt80DZHFPgpCpPQ0bemycXQIyPGR1AVXPuEIxFuY XhIC7Cm7KjIl5Hw4dB/Ya/qZfqML1fdH8plj9fmQli2cY5LMQWc+/gcG92RJoebOK8PSkFLo Gg== Message-ID: <4dac2416-b98b-5e5b-90cf-0e8d3f98a80a@03s.net> Date: Fri, 26 Jul 2019 22:13:50 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Language: tl X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: 0 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduvddrkeeggdejfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvpdfftffgtefojffquffvnecuuegrihhlohhuthemuceftddtnecunecujfgurhepuffvfhfhkffffgggjggtgfesthhqredttdefjeenucfhrhhomheptegurhhirghnucfjohcuoehmlhdophhoshhtghhrvghsqhhlsedtfehsrdhnvghtqeenucfkphepvdejrddutdegrddvuddtrddukeelnecurfgrrhgrmhepmhhouggvpehsmhhtphdphhgvlhhopegludelvddrudeikedrleelrdefvdgnpdhinhgvthepvdejrddutdegrddvuddtrddukeelpdhrvghtuhhrnhdqphgrthhhpeetughrihgrnhcujfhouceomhhlodhpohhsthhgrhgvshhqlhestdefshdrnhgvtheqpdhmrghilhhfrhhomhepmhhlodhpohhsthhgrhgvshhqlhestdefshdrnhgvthdpnhhrtghpthhtohepphhgshhqlhdqghgvnhgvrhgrlheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptd List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 25/7/19 5:24 AM, Souvik Bhattacherjee wrote: > I got this thing running and hopefully works as expected. The txns are > stored in insert_txn1.sql, insert_txn2.sql, ... > Please let me know if you find any issues with this. > Script is attached. > Even if you're using the ancient Bash version 3 (AFAIK only macOS still uses it out of the box), about half the lines are unnecessary: #!/bin/bash SECONDS=3D0 for i in {1..4} do =C2=A0=C2=A0=C2=A0 psql -d mydb -f insert_txn${i}.sql & done wait echo "Elapsed time: $SECONDS secs" Read the bash man page to understand that SECONDS "magic", and why I didn't bother with PIDs at all. I also fixed a variable-dereferencing bug in your original script ("insert_txn[$i].sql" literally expands to "insert_txn[1].sql", etc.) Best Regards, Adrian