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 1iaLdt-0003WH-FR for pgsql-admin@arkaria.postgresql.org; Thu, 28 Nov 2019 15:23:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iaLds-0008FU-65 for pgsql-admin@arkaria.postgresql.org; Thu, 28 Nov 2019 15:23:40 +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 1iaLdr-0008FM-HZ for pgsql-admin@lists.postgresql.org; Thu, 28 Nov 2019 15:23:39 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iaLdp-0001HY-0J for pgsql-admin@postgresql.org; Thu, 28 Nov 2019 15:23:38 +0000 Received: by mail-wm1-x341.google.com with SMTP id l17so11387928wmh.0 for ; Thu, 28 Nov 2019 07:23:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=JbD9mcyvkrJSlH5C/2kGA/+iM7KR1/DMmzSKeCAi/VU=; b=sCB1GVAJ5dSpsywqwPpsL39/ZDeSqhsZnl9514RlidXQ/CZAMdpZbH6VVv1Jdps16l kwR9V/vI3l9VYBkw3ikl/HNvXV9rqLbupHv27wqciR0cdcYDXvnIhWHiik3O3oC28ei6 qQ+HB66/z/HGp+wxcPCvGFcAuEcSFkJQZ4a4MZ6AteYO7gfgQwFkc/CfgMyaTI7eFpPp T2QO6FC575FYWJnIiseiCkiqDKZj76O3N1YBbHlkWQN66NGX6YbDqcz/nAuCSBr+sFKH dOWT/QxlrQcYSSFy3d4lKHG5OGMOZ/O5Rz738CMqFwMNrLs1tf8jXOD2EHYojbJwvd1q PCAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=JbD9mcyvkrJSlH5C/2kGA/+iM7KR1/DMmzSKeCAi/VU=; b=cgRd5P/2arIyJQ7wKMT0jX0Fisib1LFLKRe1wdoAMAQxRTpbSvGqmg5GPFa/jYmO/g jP4tSpejnI1yJNQgE4Vfh6aWQiFD7/PCzfqk/SLdDGR9dYtvs4hajDy+RvOqtHQtc9vO bWHlrljcISpm9MFhAyYizntGD+RicgUko530N14W6JrUqAAnt2nSIeoqzCz6+4YeEgE+ r3wJf26Fm61HxkbeeYDC/1pyTzQxyZf+jgpFTjUpglGv4+7PG0D2hmAUM+ifpK/oYYtj RLET+3W6iikuQAjN8lReIgDG5mmIiLYYVTlzCUnjPldCZ24M/mlj9UIktH/dfDmZVatG rr/w== X-Gm-Message-State: APjAAAXG2NmEnHurylqj7ITKBUeOjRhFiQAC3H51ZHAFiIJYERHuK45y jkCyjBTx979PdJU5svT1mtpfLg== X-Google-Smtp-Source: APXvYqyqerVcj2pAG4wqDCunpmXrqldKhp9GvryU/mnU0GoRdWNeWScp/t+xQNvf9OUorLtzocyVgg== X-Received: by 2002:a1c:f70a:: with SMTP id v10mr9312345wmh.159.1574954615016; Thu, 28 Nov 2019 07:23:35 -0800 (PST) Received: from localhost.localdomain (217-149-168-19.nat.highway.telekom.at. [217.149.168.19]) by smtp.gmail.com with ESMTPSA id d18sm25126010wrm.85.2019.11.28.07.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 07:23:34 -0800 (PST) Message-ID: Subject: Re: AW: No result when selecting attstattarget from pg_attribute From: Laurenz Albe To: "William Sescu (Suva)" , 'Tom Lane' Cc: "pgsql-admin@postgresql.org" Date: Thu, 28 Nov 2019 16:23:33 +0100 In-Reply-To: <9545ee300c12457f8ef09c8708d45f31@suva.ch> References: <4078c426dbbb4e18a047ec00485adba9@suva.ch> <31263.1574952854@sss.pgh.pa.us> <9545ee300c12457f8ef09c8708d45f31@suva.ch> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.5 (3.32.5-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, 2019-11-28 at 15:14 +0000, William Sescu (Suva) wrote: > Thank you Tom for clarification. However, in regards of pg_upgrade, which does not transfer statistics, how do I know > how to create the "CREATE STATISTICS" on the new PostgreSQL version? > > e.g. Developers created a whole bunch of "CREATE STATISTICS" on all kind of tables, which ends up in pg_statistic_ext view. > > select * from pg_statistic_ext; > stxrelid | stxname | stxnamespace | stxowner | stxkeys | stxkind | stxndistinct | stxdependencies > ----------+---------+--------------+----------+---------+---------+--------------+---------------------- > 35600 | s1 | 16579 | 16569 | 1 2 | {f} | | {"1 => 2": 1.000000} > > Is there any way how I can translate the view entries into into a SQL again? > > CREATE STATISTICS s1 (dependencies) ON a, b FROM t1; You are worrying without need. While the actual statistics won't be upgraded, the *definition* for extended statistics will be. So your CREATE STATISTICS won't vanish during an upgrade. You'll have to ANALYZE after upgrading so that PostgreSQL collects the extended statistics. Extended statistics are stored in the "pg_statistic_ext" catalog. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com