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 1u235B-00C8Ai-DM for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Apr 2025 07:09:17 +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 1u2359-006lAh-OH for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Apr 2025 07:09:16 +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 1u2359-006lAZ-Eb for pgsql-hackers@lists.postgresql.org; Tue, 08 Apr 2025 07:09:15 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u2357-0045Ay-1y for pgsql-hackers@postgresql.org; Tue, 08 Apr 2025 07:09:15 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-54b0d638e86so6303327e87.1 for ; Tue, 08 Apr 2025 00:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744096153; x=1744700953; darn=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=sCgaY2F08p5OOj1Wb4E4KWn1ktU7D+BO+zDyrowCxfc=; b=j56kBgasOc4sgwwcSc316d6qcsmklVYHP32CEjsUj+TrdGRDTf/8fTpto9iucJTSLv z4nKPHaGqZG2crNC+FQmwAe4NHVwu7TNe54XGUPav0AEtuRrxIrmHtdbmBreWjLm+3Ge tTI0wfyhiyKzdBB4OkW2wury3Otg7De3ZSl4sW05YTZNeYDRBg3mDdpM+M+KP3JEbUnB BLNwCjOZ3I9PYcedhS2XlXfnt2+uqRB//HrXrX3OTZf/OErIL+SVPmeSNRkNk03yd9ZH qVXAhUjmYnilViMt0HCefYYisRkpxf/6EWxUV8Lj0bUx/glMGYnE5NdNSY1ONToqW5WT lStg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744096153; x=1744700953; 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=sCgaY2F08p5OOj1Wb4E4KWn1ktU7D+BO+zDyrowCxfc=; b=CB9odTnsqLphAtDFx0zYrkmw755oHcok1Zfse6qCht0n8lMuPTMWN70JogxyFJWNRi zjr/Y2vrgCiprMwK4oHdu5NOCfi5xOiQeUAfIZNx0gvaWLe+h22TWul9W7OykAQXsuoE mIwCnShwQ0xRvua4eNEHYI+bTMMpuHdcV6ZuEeeL+b0Mdpq9OngavKCtw7VvuFmReFJi JfMV3xGP3f1k48Cd5j68dNd3FeZbHcJq/1YVV7eLUKQzpACmW6tKHEkpgHesXeI6haTS n/kDWFdwMS70EB2iFr2O8Drg3MAnoJwR9EbbPTCpfa/Snz8vu5R6zh2sC8K4wXvkux+b I35w== X-Gm-Message-State: AOJu0YzDyW5YsBF7Y9BcMhwSe4PQuhqacoZfbw3H78zRR2mdAysl9YWG 1DXhyoo8kuObU8V5/qeJis+a1irl1MdrJ1NbQ2xT0vEUgdZ3BNxmh7iD7woTBahQ5CCetMcBuy+ BMkEsBMXSKN43qb/FXpZu3fkTOQY= X-Gm-Gg: ASbGncsYbRI06X2pxdRpLVvqsB3I6eLePMXEpVB8v7qO5d6bvSIX7QnwpKd28T9EQSu Rklbd19e/3WYdTDa3HOMGyxPJINdRnL6j46JF9hAFIhGD8IJMK48VdeBHus+TiPM5O+gXuGstWw 19oqFzxI7Vd7Uc+979Sw2PN1iI+gunAngBZDFpfCVBOu+uoYm6042Eca0OTsQ= X-Google-Smtp-Source: AGHT+IE7oRvyJEtPS1LpoR/oapL91HclyWcJtEayiN9WQMiGhSvC/JInVKYIXWJhzIHf+anJyEeP/PkmQa9DuU6A1N8= X-Received: by 2002:a05:6512:e86:b0:54a:cc08:1394 with SMTP id 2adb3069b0e04-54c2278ba01mr4050985e87.33.1744096152639; Tue, 08 Apr 2025 00:09:12 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Rowley Date: Tue, 8 Apr 2025 19:09:00 +1200 X-Gm-Features: ATxdqUHvxIBEdhpWlcduIz82BQ1V7f1MlvGgGFNYEkIMZcrLNxfgTUpKzVCokr4 Message-ID: Subject: Re: Can we use Statistics Import and Export feature to perforamance testing? To: "Ryohei Takahashi (Fujitsu)" Cc: "pgsql-hackers@postgresql.org" Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 8 Apr 2025 at 12:21, Ryohei Takahashi (Fujitsu) wrote: > By using Statistics Import and Export feature, is it possible to achieve the above request by following procedure? > (1) Export the statistics from production environment by using pg_dump --statistics-only. > (2) On the staging environment, set the autovacuum related parameters to prevent autovacuum from running. > (3) Import the statistics to staging environment by using the result of (1). You could certainly test the performance, but this method isn't guaranteed to give meaningful results just because the table stats match. One important thing to remember is that the planner also looks at the *actual size* of the relation and takes that into account when scaling the statistics (see table_block_relation_estimate_size() in tableam.c). If the table sizes don't match between the two servers then there's no guarantees the planner will produce the same plan. Also, there might be other subtleties regarding OIDs of indexes which are not guaranteed to be the same after dump/restore. Given some fuzzily close enough cost estimates (See add_path() and compare_path_costs_fuzzily()), it is possible a plan would switch to using another index if sorting the indexes by their OIDs didn't match on each server. The chances of that might be fairly small, but not zero. You'd also need to ensure the configs are the same in terms of GUCs that are used for costs. You could probably use get_relation_info_hook to overwrite the sizes and make sure the indexes are in the same order, etc. David