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 1pJ5q5-0000G6-1c for pgsql-hackers@arkaria.postgresql.org; Sat, 21 Jan 2023 04:50:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pJ5q3-0000xs-Ns for pgsql-hackers@arkaria.postgresql.org; Sat, 21 Jan 2023 04:50:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pJ5q3-0000xi-Ag for pgsql-hackers@lists.postgresql.org; Sat, 21 Jan 2023 04:50:47 +0000 Received: from mail-il1-x132.google.com ([2607:f8b0:4864:20::132]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pJ5pv-0007Ge-T9 for pgsql-hackers@postgresql.org; Sat, 21 Jan 2023 04:50:46 +0000 Received: by mail-il1-x132.google.com with SMTP id r19so3367224ilt.7 for ; Fri, 20 Jan 2023 20:50:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=user-agent: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=Fnt1l288yY6xTFI8lXp/Pw5UErFKI/U7zHaw7PpXU8s=; b=A8QkVfUBDg/wCetDX0SgyRCmowdRhmontDRjGr30mhxMonUcRATqulRDlCtRe61plR GIM1oHd9gbAzCN6VH+7IneyHNENulkaoy5mcKpPxtNvyYRiAw1iUHAj7u85kEAbRE1Gh lP+fQqDKsSuvhh7DFKN+UhQ7PwZGBTcGwhf/tIY8oq47AHA4+xcUMv9PjZPogNREVaY7 zM5PPyND+LF35knQubVUG8tg+42oU0C7jNYdmGaFmBL20lFfKM9WETD6XpaEE7TdTzqN y9kEi/mgLeOJ53TrhtQHywJ8wijeDtW/eISw6Uno6ESzeT24vGh9dqDBM5uF6aiRyHeE 9BHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent: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=Fnt1l288yY6xTFI8lXp/Pw5UErFKI/U7zHaw7PpXU8s=; b=PuP6n4IZ8mz79B6KGEGMjTn7INSq0J9roZFyP+THHtzTg4e6+7AUS5lK/fgyLe/tkg 5Fikl36RyKe5goYSCOycu++gwuBSv/BKmWkhQw3VUaeyfETHO9c1bEVCZc89w+VudAWY 7C6XyouXaPnb3zsvBk39/Ne3bgB+vu5NLBdqLzTSzezsexFpX23ESxLi4I5Kt+qVX68W +lHkjtHemK+xp3PEOivNUsMkFhBQCxiLyA+181Ua9lBG80ptuzKucw0WHnlnxd6/gLEH 3XYxEFS0QrDuIYBtvXhvzq6g9wdGI0vVazrnzXYKZWrqDaOK9xCxPo8DYQFjHLwRRzGm lU/Q== X-Gm-Message-State: AFqh2ko5vvSYMJ1kzb3P/bOJAbMzKqQ0EZsmn8BZQOdeaxEThvj9u9Rq kgWrkK+yJrgEJxLnlmnyj/ETBQ== X-Google-Smtp-Source: AMrXdXtRye/4W/j2NSXZAJ6E+hN6206NM3d/ydu4m7O//ZjNtlRgLMq6+4/OL37XsUocvYXnMeIsng== X-Received: by 2002:a05:6e02:2191:b0:30f:12c9:f767 with SMTP id j17-20020a056e02219100b0030f12c9f767mr16867568ila.11.1674276639130; Fri, 20 Jan 2023 20:50:39 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id x7-20020a923007000000b0030f3441de17sm2507687ile.59.2023.01.20.20.50.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 20:50:38 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 8715C800EAD; Fri, 20 Jan 2023 22:50:37 -0600 (CST) Date: Fri, 20 Jan 2023 22:50:37 -0600 From: Justin Pryzby To: Andres Freund Cc: Tom Lane , Robert Haas , David Geier , vignesh C , Lukas Fittl , Michael Paquier , Ibrar Ahmed , Maciek Sakrejda , pgsql-hackers@postgresql.org Subject: Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc? Message-ID: <20230121045037.GN13860@telsasoft.com> References: <20230113195547.k4nlrmawpijqwlsa@awork3.anarazel.de> <20230117164758.gx4uuzhk5grw7zea@awork3.anarazel.de> <3044621.1673976417@sss.pgh.pa.us> <20230117185053.owqxw4ebp5ny6zhd@awork3.anarazel.de> <20230121004032.rzyaxmirbvt7gkd5@awork3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230121004032.rzyaxmirbvt7gkd5@awork3.anarazel.de> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jan 20, 2023 at 04:40:32PM -0800, Andres Freund wrote: > From 5a458d4584961dedd3f80a07d8faea66e57c5d94 Mon Sep 17 00:00:00 2001 > From: Andres Freund > Date: Mon, 16 Jan 2023 11:19:11 -0800 > Subject: [PATCH v8 4/5] wip: report nanoseconds in pg_test_timing > > - The i7-860 system measured runs the count query in 9.8 ms while > - the EXPLAIN ANALYZE version takes 16.6 ms, each > - processing just over 100,000 rows. That 6.8 ms difference means the timing > - overhead per row is 68 ns, about twice what pg_test_timing estimated it > - would be. Even that relatively small amount of overhead is making the fully > - timed count statement take almost 70% longer. On more substantial queries, > - the timing overhead would be less problematic. > + The i9-9880H system measured shows an execution time of 4.116 ms for the > + TIMING OFF query, and 6.965 ms for the > + TIMING ON, each processing 100,000 rows. > + > + That 2.849 ms difference means the timing overhead per row is 28 ns. As > + TIMING ON measures timestamps twice per row returned by > + an executor node, the overhead is very close to what pg_test_timing > + estimated it would be. > + > + more than what pg_test_timing estimated it would be. Even that relatively > + small amount of overhead is making the fully timed count statement take > + about 60% longer. On more substantial queries, the timing overhead would > + be less problematic. I guess you intend to merge these two paragraphs ?