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 1oo32W-0007Xc-SN for pgsql-general@arkaria.postgresql.org; Thu, 27 Oct 2022 13:35:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oo32V-0004Tq-Ik for pgsql-general@arkaria.postgresql.org; Thu, 27 Oct 2022 13:35:19 +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 1oo32V-0004Th-6q for pgsql-general@lists.postgresql.org; Thu, 27 Oct 2022 13:35:19 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1oo32T-0001M2-5h for pgsql-general@lists.postgresql.org; Thu, 27 Oct 2022 13:35:18 +0000 Received: by mail-pf1-x430.google.com with SMTP id m6so1570211pfb.0 for ; Thu, 27 Oct 2022 06:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=1ogrw/a9fE780EAnlXm0phyw7zcTWjrOMjstfgfS5V0=; b=c+5NbiqG4DvGJwkR11rumvLNUoWUFilXMhOgB+rmCx6yIru3IbIX9APNJ0qWQDYh8p XPl/J1IJx7OmwMRV99FbSACZaAMdL03X16MrWBJOdtHAolunLe357LHErnAgKca/y/ts SOupO+7JrogWSleBUOVsulZUv+WUomDxwBqbN8TqxpGzGsaUH7Jfvv4o5UM74+ZC5hMw oQatBilIG1/bP3rwfdzLhwBrgr0nlENTvessC+h0LcAybDClF42R/0xxSvPdy4vNYohp x4oafBLHwNyUCIY/bvHUC/3mV961+05AcZZVVh5Wy6aujHkgc3Qishvstnvn4NlpqRdk Hb0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=1ogrw/a9fE780EAnlXm0phyw7zcTWjrOMjstfgfS5V0=; b=QOcN0RZW52WZG0DGodseLeG1lmaa7/ejMLmCbjdR24jTtc/du8m724PYpIZr5+mqav 7rVcQRwHy3h9NhIVHi+bsCTvEXoEGXOVvphJTnoPBySIJFGdk75JBi7XcU0iT6up741t 92I0/bWd9siz54P1KPLwsClMxeQxaVoiYcHxWiy4X+smqOr7wZD++4KHriSTuXp1WLp1 /A7p29UAdE5Ls+M8GNr+hv57zxgY1l9BBne833NUZANI8WRImhWACc5C5zodx70vWIv7 Od6+vxqNRRtQXiIW+K2KCvvIpOBydvSGsCq/BdoJN+4FolH4MSS+KBbDqTdvUVxGwLjn xpYg== X-Gm-Message-State: ACrzQf3xmulac4GgRUxqgMYW2T0Ak0E/dQWMdQI7PfSgZhFjhDaafGt1 eds/A9NHk1RJpTy4YGpjTnc= X-Google-Smtp-Source: AMsMyM7kxvmBctu6ksSuUZdqugK2WbP+0rnjJ9QYoEH0bnWhKWcb8MgovfqjqLPYklzQyG4Q8M2uSA== X-Received: by 2002:aa7:8b46:0:b0:56c:349f:191e with SMTP id i6-20020aa78b46000000b0056c349f191emr11749262pfd.29.1666877714883; Thu, 27 Oct 2022 06:35:14 -0700 (PDT) Received: from jrouhaud (2001-b011-1006-d206-f9e2-1848-0e75-7d0e.dynamic-ip6.hinet.net. [2001:b011:1006:d206:f9e2:1848:e75:7d0e]) by smtp.gmail.com with ESMTPSA id f23-20020aa79697000000b0056bcc744bdbsm1167577pfk.203.2022.10.27.06.35.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 06:35:14 -0700 (PDT) Date: Thu, 27 Oct 2022 21:35:10 +0800 From: Julien Rouhaud To: Mark Mizzi Cc: pgsql-general@lists.postgresql.org Subject: Re: EXPLAIN ANALYZE does not return accurate execution times Message-ID: <20221027133510.fntozs3aubhs6olh@jrouhaud> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Thu, Oct 27, 2022 at 03:28:14PM +0200, Mark Mizzi wrote: > > EXPLAIN ANALYZE SELECT * FROM unary; > > I get the following result: > > Seq Scan on unary (cost=0.00..1637.01 rows=100001 width=18) (actual > time=0.009..6.667 rows=100001 loops=1) > Planning Time: 0.105 ms > Execution Time: 8.565 ms > > [...] > > sudo -u postgres psql -c "SELECT * FROM unary" -o /dev/null 0.01s user > 0.01s system 0% cpu 16.912 total > > I am running Postgres 14 (installed via apt) on Ubuntu 22.04. All settings > are default. > The machine is a Dell Vostro 7500. > > All commands are being run locally, so I don't think this is a network > bandwidth issue. What's going on? EXPLAIN ANALYZE doesn't output the tuples, so it hides that part of the query processing. It's usually not a problem, at least if you want to identify non optimal queries, but here you probably have the perfect scenario to notice the difference. You could try to use something like "SELECT COUNT(*) FROM unary", the timings should be closer and the query would still scan all the lines.