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 1sve2e-00GbsN-5M for pgsql-general@arkaria.postgresql.org; Tue, 01 Oct 2024 14:39:56 +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 1sve2d-000G95-Hm for pgsql-general@arkaria.postgresql.org; Tue, 01 Oct 2024 14:39:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sve2d-000G8q-6H for pgsql-general@lists.postgresql.org; Tue, 01 Oct 2024 14:39:55 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sve2a-001yGB-LY for pgsql-general@lists.postgresql.org; Tue, 01 Oct 2024 14:39:53 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-5398e4ae9efso3373539e87.1 for ; Tue, 01 Oct 2024 07:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727793590; x=1728398390; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=KetPxZ7CM/QzurGlwTYeL1dE0GzGKRVyVLJOEnMv9MU=; b=FVBGmqWj3JyNj+8ty3rsV24b3PJJuWRg627KoX1bP+L51QxPSAowDhJz/GvTBOZRYz NbpOv47XqdxBSqHDobYOGFrkDZ8a09ha4qD4YXEfdNKJT+f0fLjKnlkI0bZThFQqBGpF 3pReXEutAL/imfwST7lOvGczcWYuzp1VSD+6D4cbWaoaYDgqsSbKR5mGeAOW9ycksu1r HKQPa/ecNlOkTPguAV7kVzEBalOtXE0q55eknvPMIGOYLmYoJZUySHtYleaT9kVlGRdk du0JlCy3J1+ZwGEkR/zzzuOFpbuTpPWyu89z3UE8DA1zltAcm0QTfWxzayO0XdHu9KGA F3Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727793590; x=1728398390; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KetPxZ7CM/QzurGlwTYeL1dE0GzGKRVyVLJOEnMv9MU=; b=Ii4cNTAevUMJZbXTGJIfe0PxvP/dBjEy5mWEezKuiyF5gpUmLlcPjv0ugK9u8MWEKe HO/9LGqTPMr85mBnWRmhNyDAMn/98gKmRlWQdLKBTwlW5s/RGEHLmOv0NsE7Z6ELV/ik eEKFS5IBMFiaAHKdr+AJWwv0M8n8wT0PKr67tonfaNpnKRm13xenkJI/Hc+VHGwPSpRn mFEyOPud+htkRrq4++o1Z3ASxNsBKKS9x0ZRJ4KpGs4m7dV1QTTiYSRFoYWjTYHNxQzp zuqYM4s81Ea6tyY4vzSQ3gCkzsGv5ciD83Cm9qfjjPXUB9nHms3s5/HuAQ0MbSLXIk6v 7DpQ== X-Gm-Message-State: AOJu0YyHz4GHnW+5FTMDG4kPgC0Qsv0NzPIHnCK82DrcWqg1R9bzBseP n9dw+ToFSd1n+Tf7qit70XCdCjcOauohZ6+ICFTWYycRBQzubxXcORHxsSrPAZOWkXbZNpfAt5d 9k9Dd27WM2CaK94HIHOF/iRpU/Vp2Gjy4 X-Google-Smtp-Source: AGHT+IG1Hb82KdWjj9zm3awWfglcLe9ntqBw+ynWwydA4paBf1FTjzCXORDCnyWPN1KEvIQHmJ5f4PfUBdjZCn868yQ= X-Received: by 2002:a05:6512:3a8e:b0:535:6ba7:7725 with SMTP id 2adb3069b0e04-5389fc3319emr7925048e87.3.1727793589655; Tue, 01 Oct 2024 07:39:49 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Greg Sabino Mullane Date: Tue, 1 Oct 2024 10:39:11 -0400 Message-ID: Subject: Re: Reading execution plan - first row time vs last row time To: =?UTF-8?B?UGVjc8O2ayBKw6Fu?= Cc: "pgsql-general@lists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000281dd206236b4b87" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000281dd206236b4b87 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Oct 1, 2024 at 9:53=E2=80=AFAM Pecs=C3=B6k J=C3=A1n wrote: > We see significant difference in explain analyze Actual time in the first > line of execution plan and Execution time in the last line of execution > plan. What can be the reason? > > > > For example, first line of execution plan: > > Gather (cost=3D1038.49..257627100.42 rows=3D7943222226 width=3D104) (act= ual > time=3D531.925..3673159.806 rows=3D7943221053 loops=3D1) > It takes an hour for Postgres to gather up 7.9 BILLION (!) rows, but then it is going to take additional time to do something with all of those rows. That's where the rest of your time is going. Seeing your actual query would be a help. If this is a CTAS (Create Table As Select), then you have an hour for the 'Select' part, and the rest of your time is in the 'Create Table' part. Cheers, Greg --000000000000281dd206236b4b87 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Oct 1, 2024 at 9:53=E2=80=AFAM Pe= cs=C3=B6k J=C3=A1n <jan.pecsok= @profinit.eu> wrote:

We see significant difference in explain analyze Act= ual time in the first line of execution plan and Execution time in the last= line of execution plan. What can be the reason?

=C2=A0

For example, first line of execution plan:=

Gather=C2=A0 (cost=3D1038.49..257627100.42 rows=3D79= 43222226 width=3D104) (actual time=3D531.925..3673159.806 rows=3D7943221053= loops=3D1)


It takes = an hour for Postgres to gather up 7.9 BILLION (!) rows, but then it is goin= g to take additional time to do something with all of those rows. That'= s where the rest of your time is going. Seeing your actual query would be a= help. If this is a CTAS (Create Table As Select), then you have an hour fo= r the 'Select' part, and the rest of your time is in the 'Creat= e Table' part.

Cheers,
Greg

--000000000000281dd206236b4b87--