CREATE INDEX ONLY on a partitioned table?

2021-06-28 Thread Ron
Postgresql 12.5. https://www.postgresql.org/docs/12/ddl-partitioning.html mentions creating indices on children, and then attaching them to a table which previously had CREATE INDEX ... ONLY ON executed. Can I do something similar on an existing table (for example, on a heavily partitioned t

Re: ALTER TABLE ... DETACH PARTITION just sitting there

2021-06-28 Thread Laurenz Albe
On Mon, 2021-06-28 at 16:52 -0500, Ron wrote: > On 6/28/21 4:16 PM, Tom Lane wrote: > > Ron writes: > > > AWS RDS Postgresql 12.5. > > > We've got a table partitioned by month range (FOR VALUES FROM > > > ('2011-07-01') > > > TO (2011-08-01')), and I've been detaching partitions from oldest to >

Re: Use case stuck due to Partitioning

2021-06-28 Thread David G. Johnston
On Mon, Jun 28, 2021 at 2:51 PM Michael Lewis wrote: > I am unclear exactly what you want to do with modified_date. Can you write > pseudo code perhaps? > > I second this. While I'm not all that familiar with partitioning I am readily getting the feeling that whether or not partitioning is used

Re: ALTER TABLE ... DETACH PARTITION just sitting there

2021-06-28 Thread Ron
On 6/28/21 4:16 PM, Tom Lane wrote: Ron writes: AWS RDS Postgresql 12.5. We've got a table partitioned by month range (FOR VALUES FROM ('2011-07-01') TO (2011-08-01')), and I've been detaching partitions from oldest to newest, one at a time. Whenever it's failed due to a FK constraint (and ther

Re: Use case stuck due to Partitioning

2021-06-28 Thread Michael Lewis
I am unclear exactly what you want to do with modified_date. Can you write pseudo code perhaps? It sounds like you are wanting to union all the results of the query you gave, with the results of a similar query where modified_date >= '2021-03-01 08:16:13.589' and created_at < '2021-03-01 08:16:13.

Re: ALTER TABLE ... DETACH PARTITION just sitting there

2021-06-28 Thread Alvaro Herrera
On 2021-Jun-28, Ron wrote: > We've got a table partitioned by month range (FOR VALUES FROM ('2011-07-01') > TO (2011-08-01')), and I've been detaching partitions from oldest to newest, > one at a time. Whenever it's failed due to a FK constraint (and there are > many of them!), I dropped the "same

Re: ALTER TABLE ... DETACH PARTITION just sitting there

2021-06-28 Thread Tom Lane
Ron writes: > AWS RDS Postgresql 12.5. > We've got a table partitioned by month range (FOR VALUES FROM ('2011-07-01') > TO (2011-08-01')), and I've been detaching partitions from oldest to newest, > one at a time. Whenever it's failed due to a FK constraint (and there are > many of them!), I d

ALTER TABLE ... DETACH PARTITION just sitting there

2021-06-28 Thread Ron
AWS RDS Postgresql 12.5. We've got a table partitioned by month range (FOR VALUES FROM ('2011-07-01') TO (2011-08-01')), and I've been detaching partitions from oldest to newest, one at a time. Whenever it's failed due to a FK constraint (and there are many of them!), I dropped the "same mon

Re: Use case stuck due to Partitioning

2021-06-28 Thread Shubham Mittal
Hi Michael, Yes I have a btree index on the *modified_date* column currently. SELECT * FROM partitioned_table where A ='Value' AND created_date >= '2021-03-01 08:16:13.589' and created_date <= '2021-04-02 08:16:13.589' ORDER BY viewpriority desc OFFSET 0 ROWS FETCH NEXT 200 ROWS ONLY; Here

Re: Use case stuck due to Partitioning

2021-06-28 Thread Michael Lewis
Do you have an index on the "updated_at" field and found that the query is too slow? Do you have an example query?

Use case stuck due to Partitioning

2021-06-28 Thread Shubham Mittal
Hi All, Please find my use case below and suggest the appropriate solution: We have done declarative partitioning over our table A based on some key and further range sub partitioned each partition on the basis of createddate range of 90 days. In the search query to display last 90 day data , I

RE: Re: WARNING: skipping "pg_database" --- only superuser can analyze it

2021-06-28 Thread Abraham, Danny
Right to the point ==> set client_min_messages=error; Solved it Thanks -Original Message- From: Tom Lane Sent: Monday, June 28, 2021 5:53 PM To: Abraham, Danny Cc: pgsql-gene...@postgresql.org Subject: [EXTERNAL] Re: WARNING: skipping "pg_database" --- only superuser can analyze it "

Re: Ubuntu 14.04 (trusty) Postgres 13 deb package

2021-06-28 Thread Joshua Drake
On Sun, Jun 27, 2021 at 10:42 AM Bhavesh Mistry wrote: > Hi All, > > I was trying to install PSQL 13 on Ubuntu 14.04 (trusty) but I could not > find the package. It seems the path has been removed. Can you please tell > me how to build deb package for trusty from psql source? I tried psql 13 >

Re: WARNING: skipping "pg_database" --- only superuser can analyze it

2021-06-28 Thread Tom Lane
"Abraham, Danny" writes: > Good old "analyze;" will run smoothly on 11.5... > But on 12.6 will skip and warn on any pg_catalog/information_schema table. Hm, for me there are such warnings on 11.x too. Not as many --- it looks like indexes are mentioned as well in 12.x. But it's never been th

Re: schema prefixes in default values (was RE: removing "serial" from table definitions).

2021-06-28 Thread Tom Lane
Marc Mamin writes: > it seems that our problem had nothing to do with serial, but with the way > schema prefixes are handled in column default values. > pg_attrdef.adsrc: > filled when the defaut value is defined. contains a schema prefix only when > required at this creation time. Is constan

WARNING: skipping "pg_database" --- only superuser can analyze it

2021-06-28 Thread Abraham, Danny
Hi, Good old "analyze;" will run smoothly on 11.5... But on 12.6 will skip and warn on any pg_catalog/information_schema table. Pg_catalog is on Usage only on both databases (11.5 and 12.6). Questions: 1. Has the behavior changed in 12.6? 2.How can I analyze on public tables (No syntax lik

Memory activities to monitor in statistics collector?

2021-06-28 Thread Yu Watanabe
Dear community I would like to ask a question regarding system monitoring. I am sorry if this question was asked before. My postgresql is running on Azure database for Postgresql (ver 12) which runs on cloud platform. My goal is to observe memory statistics to see if there are any memory suspicio

schema prefixes in default values (was RE: removing "serial" from table definitions).

2021-06-28 Thread Marc Mamin
Marc Mamin writes: > > Yes, I undersand that serial is just a hint at table creation time, but is > > there a place in catalog where we can see if the table was created using > > 'serial' ? > > No. Where the docs say "these are equivalent", they mean that very literally. > > > The difference

Re: Overlapping timestamptz ranges with priority

2021-06-28 Thread Ray O'Donnell
On 28/06/2021 00:52, Adrian Klaver wrote: On 6/27/21 3:41 PM, Ray O'Donnell wrote: Here's a slightly simplified example: create table bookings ( booking_id bigint not null, booking_time tstzrange not null, constraint bookings_pk primary key (booking_id) ); It seems to me th

pg_restore disable-triggers current session

2021-06-28 Thread Dolors Segura
Hi, I'm not sure if the disable-triggers option of data-only restore disable the triggers only in the current session or are disabled to everyone who is working in the database at that moment. Thanks. Dolors

Re: Overlapping timestamptz ranges with priority

2021-06-28 Thread Alban Hertroys
> On 28 Jun 2021, at 0:41, Ray O'Donnell wrote: > > Hi all, > (…) > create table bookings ( >booking_id bigint not null, >booking_time tstzrange not null, > >constraint bookings_pk primary key (booking_id) > ); > > insert into bookings (booking_id, booking_time) values > (1, ts