From: | "William Sescu (Suva)" <william(dot)sescu(at)suva(dot)ch> |
---|---|
To: | "pgsql-admin(at)postgresql(dot)org" <pgsql-admin(at)postgresql(dot)org> |
Subject: | No result when selecting attstattarget from pg_attribute |
Date: | 2019-11-28 09:55:10 |
Message-ID: | 4078c426dbbb4e18a047ec00485adba9@suva.ch |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Hello %
I was following the create statistics example from the doc
https://www.postgresql.org/docs/11/sql-createstatistics.html
and wondered why I don't see any results when selecting attstattarget from pg_attribute.
Version: PostgreSQL 11.5
(klb(at)[local]:55000)[knowledgebase]> CREATE TABLE t1 (
> a int,
> b int
> );
CREATE TABLE
(klb(at)[local]:55000)[knowledgebase]> INSERT INTO t1 SELECT i/100, i/500
> FROM generate_series(1,1000000) s(i);
INSERT 0 1000000
(klb(at)[local]:55000)[knowledgebase]> ANALYZE t1;
ANALYZE
-- No custom statistics here, which is OK
(klb(at)[local]:55000)[knowledgebase]> select attrelid::regclass as name, attname, attstattarget from pg_attribute where attname in ('a','b');
name | attname | attstattarget
------+---------+---------------
t1 | a | -1
t1 | b | -1
(2 rows)
(klb(at)[local]:55000)[knowledgebase]> SELECT attrelid::regclass, attname, attstattarget FROM pg_attribute WHERE attstattarget > 0 order by attstattarget desc;
attrelid | attname | attstattarget
----------+---------+---------------
(0 rows)
-- Now I create the custom statistics, however, attstattarget is still -1
(klb(at)[local]:55000)[knowledgebase]> CREATE STATISTICS s1 (dependencies) ON a, b FROM t1;
CREATE STATISTICS
(klb(at)[local]:55000)[knowledgebase]> select attrelid::regclass as name, attname, attstattarget from pg_attribute where attname in ('a','b');
name | attname | attstattarget
------+---------+---------------
t1 | a | -1
t1 | b | -1
(2 rows)
Am I looking at the wrong view? I am planning to do some upgrades to 12.x, and therefore, I created this little test case
to make sure that I don't forget to set custom statistics on the new version, if there are any.
Cheers
William
________________________________
Disclaimer:
Diese Nachricht und ihr eventuell angeh?ngte Dateien sind nur f?r den Adressaten bestimmt. Sie kann vertrauliche oder gesetzlich gesch?tzte Daten oder Informationen beinhalten. Falls Sie diese Nachricht irrt?mlich erreicht hat, bitten wir Sie h?flich, diese unter Ausschluss jeglicher Reproduktion zu l?schen und die absendende Person zu benachrichtigen. Danke f?r Ihre Hilfe.
This message and any attached files are for the sole use of the recipient named above. It may contain confidential or legally protected data or information. If you have received this message in error, please delete it without making any copies whatsoever and notify the sender. Thank you for your assistance.
From | Date | Subject | |
---|---|---|---|
Next Message | Laurenz Albe | 2019-11-28 14:23:15 | Re: No result when selecting attstattarget from pg_attribute |
Previous Message | Jakub Olczyk | 2019-11-25 08:09:21 | Re: Trouble setting up Streaming Replication with Barman |