On Tue, 2025-04-08 at 17:24 +1200, David Rowley wrote:
> I was surprised to see when I did pg_dump -T just_this_table that I
> also got statistics data for all tables in the database.
-T means "exclude this pattern"
I tried a few basic variations and they seemed to do what I expected:
CREATE TABLE mytable1(i INT);
INSERT INTO mytable1 VALUES(1);
CREATE TABLE mytable2(i INT);
INSERT INTO mytable2 VALUES(2);
CREATE TABLE mytable3(i INT);
INSERT INTO mytable3 VALUES(3);
ANALYZE;
$ ./bin/pg_dump -t mytable1 postgres | grep "Name: mytable"
-- Name: mytable1; Type: TABLE; Schema: public; Owner: jdavis
-- Data for Name: mytable1; Type: TABLE DATA; Schema: ...
-- Statistics for Name: mytable1; Type: STATISTICS DATA; ...
$ ./bin/pg_dump -T mytable1 postgres | grep "Name: mytable"
-- Name: mytable2; Type: TABLE; Schema: public; Owner: jdavis
-- Name: mytable3; Type: TABLE; Schema: public; Owner: jdavis
-- Data for Name: mytable2; Type: TABLE DATA; Schema: ...
-- Data for Name: mytable3; Type: TABLE DATA; Schema: ...
-- Statistics for Name: mytable2; Type: STATISTICS DATA; ...
-- Statistics for Name: mytable3; Type: STATISTICS DATA; ...
If you still see a problem, please let me know.
Regards,
Jeff Davis