How effectively do the indexing in postgres in such cases

2024-09-07 Thread sud
.tab2_id and tab1.col1=<:input_col1> and tab2.col2=<:input_col2> order by tab1.create_timestamp desc limit 100 offset 100; Regards Sud

Re: Insert query performance

2024-08-20 Thread sud
On Mon, Aug 19, 2024 at 1:25 PM Muhammad Ikram wrote: > Hi Sud, > > Please make following change in your postgresql.conf file > > log_statement = 'all' > > Will this put all the internal sql query or the recursive query entries in the pg_stats_statement view whic

Re: Insert query performance

2024-08-20 Thread sud
On Mon, Aug 19, 2024 at 4:33 PM David Rowley wrote: > On Mon, 19 Aug 2024 at 19:48, sud wrote: > > In a version 15.4 postgres database, Is it possible that , if we have > two big range partition tables with foreign key relationships between them, > insert into the child table can

Insert query performance

2024-08-19 Thread sud
f the incoming row to the child table already exists in the parent table or not? Regards Sud

Re: Column type modification in big tables

2024-08-10 Thread sud
On Sat, Aug 10, 2024 at 12:52 AM Lok P wrote: > > On Fri, Aug 9, 2024 at 9:19 PM Greg Sabino Mullane > wrote: > >> On Fri, Aug 9, 2024 at 6:39 AM Lok P wrote: >> >>> Thank you so much. Will definitely try to evaluate this approach. The >>> Only concern I have is , as this data is moving downstr

Re: Column type modification in big tables

2024-08-07 Thread sud
On Wed, Aug 7, 2024 at 5:00 PM Lok P wrote: > > > On Wed, Aug 7, 2024 at 4:51 PM sud wrote: > >> >> >> Others may correct but i think, If you don't have the FK defined on these >> columns you can do below. >> >> >> --Alter table add

Re: Column type modification in big tables

2024-08-07 Thread sud
On Wed, Aug 7, 2024 at 4:39 PM Lok P wrote: > Hello all, > We have a postgres table which is a range partitions on a timestamp column > having total size ~3TB holding a total ~5billion rows spanning across ~150 > daily partitions and there are ~140+columns in the table. Also this table > is a chi

Re: Trigger usecase

2024-07-30 Thread sud
ure/functions. Hope this understanding correct. Regards Sud

Trigger usecase

2024-07-30 Thread sud
stand, technically its possible bith the way, but want to understand experts opinion on this and pros ans cons? Regards Sud

Re: Dropping column from big table

2024-07-15 Thread sud
On Tue, Jul 16, 2024 at 10:26 AM David G. Johnston < david.g.johns...@gmail.com> wrote: > > > On Monday, July 15, 2024, David G. Johnston > wrote: > >> On Monday, July 15, 2024, sud wrote: >> >>> >>> However even with "vacuum full",

Re: Dropping column from big table

2024-07-15 Thread sud
On Tue, Jul 16, 2024 at 6:07 AM Peter J. Holzer wrote: > > > But the only issue would be "VACUUM FULL" will take a table lock and > also it > > may take longer to run this vacuum on the full table considering the > size of > > the table in TB's. Thus, is it fine to just leave it post execution of

Re: Dropping column from big table

2024-07-15 Thread sud
On Mon, Jul 15, 2024 at 7:58 PM Peter J. Holzer wrote: > > > Hm, true. > > > > You can always do > > > > UPDATE tab SET id = id; > > > > followed by > > > > VACUUM (FULL) tab; > > Yes, that should work. It needs about twice the size of the table in > temporary space, though. > > Since the OP

Re: Dropping column from big table

2024-07-11 Thread sud
On Thu, 11 Jul, 2024, 12:46 pm Ron Johnson, wrote: > On Wed, Jul 10, 2024 at 11:28 PM sud wrote: > >> >> >> >> Thank you so much. When you said *"you can execute one of the forms of >> ALTER TABLE that performs a rewrite* >> *of the whole table.&qu

Re: Dropping column from big table

2024-07-10 Thread sud
On Thu, Jul 11, 2024 at 2:52 AM Adrian Klaver wrote: > > https://www.postgresql.org/docs/current/sql-altertable.html > > "The DROP COLUMN form does not physically remove the column, but simply > makes it invisible to SQL operations. Subsequent insert and update > operations in the table will stor

Dropping column from big table

2024-07-10 Thread sud
p/add columns from such a big table and what will be the consequence of this in regards to vacuum, post this activity? Or if any other issues we may face post this? Regards Sud

Re: Load a csv or a avro?

2024-07-06 Thread sud
On Fri, Jul 5, 2024 at 8:24 PM Adrian Klaver wrote: > On 7/5/24 02:08, sud wrote: > > Hello all, > > > > Its postgres database. We have option of getting files in csv and/or in > > avro format messages from another system to load it into our postgres > > databa

Re: Load a csv or a avro?

2024-07-06 Thread sud
On Fri, Jul 5, 2024 at 3:27 PM Kashif Zeeshan wrote: > Hi > > There are different data formats available, following are few points for > there performance implications > > 1. CSV : It's easy to use and widely supported but it can be slower due to > parsing overload. > 2. Binary : Its faster to lo

Load a csv or a avro?

2024-07-05 Thread sud
Hello all, Its postgres database. We have option of getting files in csv and/or in avro format messages from another system to load it into our postgres database. The volume will be 300million messages per day across many files in batches. My question was, which format should we chose in regards

Design for dashboard query

2024-06-15 Thread sud
Hello All, Its postgres version 15.4. We are having a requirement in which aggregated information for all the users has to be displayed on the UI screen. It should show that information on the screen. So basically, it would be scanning the full table data which is billions of rows across many mont

Re: Creating big indexes

2024-06-11 Thread sud
On Sun, Jun 9, 2024 at 1:40 PM Lok P wrote: > On Sun, Jun 9, 2024 at 10:39 AM Lok P wrote: > >> >> >> On Sun, Jun 9, 2024 at 10:36 AM sud wrote: >> >>> >>> You can first create the index on the table using the "On ONLY"keyword, >>

Re: Question on pg_cron

2024-06-08 Thread sud
On Sat, Jun 8, 2024 at 10:05 PM yudhi s wrote: > > > On Sat, 8 Jun, 2024, 9:53 pm Ron Johnson, wrote: > >> On Sat, Jun 8, 2024 at 5:31 AM yudhi s >> wrote: >> >>> Hello All, >>> >>> We have around 10 different partition tables for which the partition >>> maintenance is done using pg_partman ext

Re: Creating big indexes

2024-06-08 Thread sud
On Sat, Jun 8, 2024 at 12:53 PM Lok P wrote: > Hello, > We have a few tables having size ~5TB and are partitioned on a timestamp > column. They have ~90 partitions in them and are storing 90 days of data. > We want to create a couple of indexes on those tables. They are getting the > incoming tra

Re: Long running query causing XID limit breach

2024-06-08 Thread sud
On Thu, Jun 6, 2024 at 12:52 AM yudhi s wrote: > On Wed, Jun 5, 2024 at 3:52 PM Laurenz Albe > wrote: > >> >> There should never be a restart unless you perform one or the standby >> crashes. >> If you mean that you want to avoid a crash caused by a full disk on the >> standby, >> the answer is

Re: Long running query causing XID limit breach

2024-06-05 Thread sud
e the timeout (not -1). > > > > On Wed, Jun 5, 2024 at 8:25 AM sud wrote: > >> Hello Laurenz, >> >> Thank you so much.This information was really helpful for us >> understanding the working of these parameters. >> >> One follow up ques

Re: Long running query causing XID limit breach

2024-06-04 Thread sud
Hello Laurenz, Thank you so much.This information was really helpful for us understanding the working of these parameters. One follow up question i have , as we are setting one of the standby/replica with value idle_in_transaction_session_timeout=-1 which can cause the WAL's to be heavily backlog

Re: Long running query causing XID limit breach

2024-05-26 Thread sud
On Mon, May 27, 2024 at 12:55 AM Torsten Förtsch wrote: > On Sun, May 26, 2024 at 8:46 PM sud wrote: > >> Would you agree that we should have two standby, one with default >> max_standby_streaming_delay (say 10 sec ) which will be mainly used as high >> availability

Re: Long running query causing XID limit breach

2024-05-26 Thread sud
On Sun, May 26, 2024 at 11:18 PM Torsten Förtsch wrote: > Each query on the replica has a backend_xmin. You can see that in > pg_stat_activity. From that backend's perspective, tuples marked as deleted > by any transaction greater or equal to backend_xmin are still needed. This > does not depend

Re: Long running query causing XID limit breach

2024-05-26 Thread sud
On Sun, May 26, 2024 at 1:43 PM Torsten Förtsch wrote: > On Sat, May 25, 2024 at 11:00 PM sud wrote: > >> >> But i have one question here , does max_standby_streaming_delay = 14 , >> means the queries on the standby will get cancelled after 14 seconds? >> > >

Re: Long running query causing XID limit breach

2024-05-25 Thread sud
On Sun, May 26, 2024 at 2:24 AM yudhi s wrote: > > > *hot_standby_feedback ON and max_standby_streaming_delay = -1:* > Ensures that long-running queries on the standby are not interrupted. The > primary waits indefinitely to avoid vacuuming rows needed by standby > queries. > But Can lead to sign

Re: Long running query causing XID limit breach

2024-05-23 Thread sud
On Thu, May 23, 2024 at 8:11 PM Laurenz Albe wrote: > On Thu, 2024-05-23 at 18:15 +0530, sud wrote: > > On Thu, May 23, 2024 at 1:45 PM Laurenz Albe > wrote: > > > If a long running query on the standby influences the primary, that > means that > > > you have

Re: Long running query causing XID limit breach

2024-05-23 Thread sud
On Thu, May 23, 2024 at 1:45 PM Laurenz Albe wrote: > > > If a long running query on the standby influences the primary, that means > that > you have "hot_standby_feedback" set to "on". Set it to "off". > > > Will the setting up of "hot_standby_feedback" value to OFF will cause the reader instan

Re: Long running query causing XID limit breach

2024-05-23 Thread sud
On Thu, May 23, 2024 at 1:22 PM Laurenz Albe wrote: > On Thu, 2024-05-23 at 02:46 +0530, sud wrote: > > It's RDS postgres version 15.4. We suddenly saw the > "MaximumUsedTransactionIDs" > > reach to ~1.5billion and got alerted by team members who mentioned the

Re: Long running query causing XID limit breach

2024-05-22 Thread sud
ailure. Hope my understanding is correct here. On Thu, May 23, 2024 at 11:41 AM sud wrote: > > On Thu, May 23, 2024 at 10:42 AM Muhammad Salahuddin Manzoor < > salahuddi...@bitnine.net> wrote: > >> Greetings, >> >> Running `VACUUM table_name;` on a partitioned ta

Re: Long running query causing XID limit breach

2024-05-22 Thread sud
On Thu, May 23, 2024 at 10:42 AM Muhammad Salahuddin Manzoor < salahuddi...@bitnine.net> wrote: > Greetings, > > Running `VACUUM table_name;` on a partitioned table will vacuum each > partition individually, not the whole table as a single unit. > > Yes, running `VACUUM table_name;` frequently on

Re: Long running query causing XID limit breach

2024-05-22 Thread sud
On Thu, May 23, 2024 at 9:00 AM Muhammad Salahuddin Manzoor < salahuddi...@bitnine.net> wrote: > Greetings, > > In high-transaction environments like yours, it may be necessary to > supplement this with manual vacuuming. > > Few Recommendations > > Monitor Long-Running Queries try to optimize. > O

Long running query causing XID limit breach

2024-05-22 Thread sud
on prod databases, to restrict the long running transactions/queries and avoid such issues in future. Correct me if I'm wrong. Regards Sud

Re: Adding constraints faster

2024-05-14 Thread sud
On Wed, May 15, 2024 at 2:09 AM Ron Johnson wrote: > On Tue, May 14, 2024 at 3:59 PM sud wrote: > >> * >> > ALTER TABLE ADD FOREIGN KEY ... NOT VALID. >> ALTER TABLE ... VALIDATE CONSTRAINT; >> >> > This is what we did, back in the PG 12.x

Adding constraints faster

2024-05-14 Thread sud
other options available to make this foreign key addition faster with existing data in it? ** ALTER TABLE ADD FOREIGN KEY ... NOT VALID. ALTER TABLE ... VALIDATE CONSTRAINT; Regards Sud

Monitoring and debugging historical performance

2024-04-27 Thread sud
there exists some options as i googled in the internet like pg_sentinel,pgsnapper, pg_collector. Wanted to check, if anybody used these utilities and suggest any of them to use for a longer term use? Regards Sud

Re: Timestamp conversion Error in dynamic sql script

2024-04-03 Thread sud
This one worked. Thank you so much. On Wed, Apr 3, 2024 at 2:27 AM Erik Wienhold wrote: > On 2024-04-02 22:08 +0200, sud wrote: > > On Tue, Apr 2, 2024 at 7:46 PM Greg Sabino Mullane > > wrote: > > > > Now this block seems to be failing near the "LIKE" oper

Re: Timestamp conversion Error in dynamic sql script

2024-04-02 Thread sud
On Tue, Apr 2, 2024 at 7:46 PM Greg Sabino Mullane wrote: > 1. Declare start_date as DATE when you want to add days with date + int >> 2. Keep TIMESTAMP and use start_date + make_interval(days => i) >> > > Also > > 0. Use TIMESTAMPTZ not TIMESTAMP > > > Thank you so much. That helped. Now this b

Timestamp conversion Error in dynamic sql script

2024-04-01 Thread sud
Hello , I am trying to create a block which will create a few partitions dynamically and also insert ~1million rows into each of those partitions. Not able to figure out why it's giving below error during timezone conversion while defining the partitions even though I used the typecast? CREATE TAB

Re: Not able to purge partition

2024-04-01 Thread sud
On Thu, Mar 21, 2024 at 6:18 PM Laurenz Albe wrote: > > > [create some partitions, then drop a partition of the referenced table] > > > > > SQL Error [P0001]: ERROR: cannot drop table > schema1.test_part_drop_parent_p2024_02_01 because other objects depend on it > > CONTEXT: SQL statement "DROP T

Re: Grants and privileges issue

2024-03-28 Thread sud
On Fri, Mar 29, 2024 at 2:43 AM Adrian Klaver wrote: > > > On 3/28/24 2:10 PM, sud wrote: > > Hi, It's postgres 15.4. > > > > We want to give required privilege to certain users or roles and ensure > > to not to provide any elevated privilege. I have below q

Grants and privileges issue

2024-03-28 Thread sud
h the data from the cron and partman schema tables. grant select on cron.job to ; grant select on cron.job_run_details to ; grant select on partman.part_config to ; Regards Sud

Re: Is this a buggy behavior?

2024-03-24 Thread sud
On Sun, Mar 24, 2024 at 8:47 PM Tom Lane wrote: > Thiemo Kellner writes: > > Am 24.03.2024 um 15:54 schrieb Erik Wienhold: > >> This is required by the SQL standard: columns of a primary key must be > >> NOT NULL. Postgres automatically adds the missing NOT NULL constraints > >> when defining a

Is this a buggy behavior?

2024-03-24 Thread sud
ue in column "c1" of relation "test1" violates not-null constraintDETAIL: Failing row contains (null, 123).* insert into test1 values('123','123'); --works fine as expected Regards Sud

Re: Question related to partitioning with pg_partman

2024-03-10 Thread sud
On Sun, Mar 10, 2024 at 11:31 PM Adrian Klaver wrote: > 1) The partition will be across one day(24 hours) it is just the times > may confuse people. Per you example 2024-03-07 00:00:00+00 is the same > time as 2024-03-06 19:00:00-05 for EST. The issue is that the +00 and > -05 maybe ignored. Als

Re: Question related to partitioning with pg_partman

2024-03-10 Thread sud
On Sun, Mar 10, 2024 at 10:32 PM Adrian Klaver wrote: > On 3/10/24 05:12, sud wrote: > > > > In my example in the first post, I see, if someone connected to a RDS > > Postgres database and run the create partition command using pg_partman > > by setting the timez

Re: Question related to partitioning with pg_partman

2024-03-10 Thread sud
On Sat, Mar 9, 2024 at 3:41 AM Adrian Klaver wrote: > On 3/8/24 00:23, sud wrote: > > > > Starting a new thread... > > > > Something interesting and not sure if its expected behaviour as below. > > We are also confused a bit here. > > > > In the below

Re: Question related to partitioning with pg_partman

2024-03-08 Thread sud
Can somebody help me to understand the behaviour? >

Question related to partitioning with pg_partman

2024-03-08 Thread sud
Starting a new thread... Something interesting and not sure if its expected behaviour as below. We are also confused a bit here. In the below example we created two partitioned tables on timestamptz type columns with different time zones and the child partitions are created appropriately with bou

Re: Is partition pruning impacted by data type

2024-03-07 Thread sud
('2024-03-11 00:00:00-05') TO ('2024-03-12 00:00:00-05') SET SESSION TIME ZONE 'UTC'; test_timestamp2_default DEFAULT test_timestamp2_p2024_03_07 FOR VALUES FROM ('2024-03-07 *05:00:00+00*') TO ('2024-03-08 05:00:00+00') test_timestamp2_p2024_03_08 FOR VALUES FROM ('2024-03-08 *05:00:00+00*') TO ('2024-03-09 05:00:00+00') test_timestamp2_p2024_03_09 FOR VALUES FROM ('2024-03-09 *05:00:00+00*') TO ('2024-03-10 05:00:00+00') test_timestamp2_p2024_03_10 FOR VALUES FROM ('2024-03-10 *05:00:00+00*') TO ('2024-03-11 05:00:00+00') test_timestamp2_p2024_03_11 FOR VALUES FROM ('2024-03-11 *05:00:00+00*') TO ('2024-03-12 05:00:00+00') Regards Sud

Re: Is partition pruning impacted by data type

2024-03-05 Thread sud
negative impact on aggregation type queries , not sure how but will try to test it. Thanks again for the response. On Wed, Mar 6, 2024 at 12:35 AM Lok P wrote: > > On Tue, Mar 5, 2024 at 1:09 AM sud wrote: > >> >> However the question we have is , >> 1)If there is

Is partition pruning impacted by data type

2024-03-04 Thread sud
db time, the user's one day transaction might span across two daily partitions. Thanks and Regards Sud

Re: Question on Table creation

2024-02-29 Thread sud
in pg_partman, so please plan ahead for that during major version upgrading if it applies to you. On Thu, Feb 29, 2024 at 1:58 AM veem v wrote: > > On Wed, 28 Feb 2024 at 01:24, sud wrote: > >> While testing the pg_partman extension I see it by default creates a >> &quo

Re: Question on Table creation

2024-02-27 Thread sud
e table is by default created in the partman schema but it also works without error, if we pass the template table to be created in the application schema. So is there any downside of having the template table reside in the application schema? Thanks And Regards Sud

Re: Creating table and indexes for new application

2024-02-23 Thread sud
On Fri, 23 Feb, 2024, 1:28 pm yudhi s, wrote: > > > On Fri, 23 Feb, 2024, 1:20 pm sud, wrote: > >> >> >> On Fri, 23 Feb, 2024, 12:41 pm Laurenz Albe, >> wrote: >> >>> On Fri, 2024-02-23 at 02:05 +0530, yudhi s >>> >>>

Re: Creating table and indexes for new application

2024-02-22 Thread sud
On Fri, 23 Feb, 2024, 12:41 pm Laurenz Albe, wrote: > On Fri, 2024-02-23 at 02:05 +0530, yudhi s > > > 2)Should we be creating composite indexes on each foreign key for table2 > and table3, because > > any update or delete on parent is going to take lock on all child > tables? > > Every foreign

Re: Question on Table creation

2024-02-22 Thread sud
Thank you so much. This really helped. Regards Sud >

Question on Table creation

2024-02-20 Thread sud
t;,"PARENT_CREATE_TIMESTAMP") ON UPDATE RESTRICT ON DELETE RESTRICT ); CREATE INDEX "XIF1CHILD_STATUS" ON "Schema_Name"."CHILD_STATUS" ( "CHILD_IDENTIFIER", "CHILD_CREATE_TIMESTAMP" ); ALTER TABLE "Schema_Name"."CHILD_STATUS" OWNER TO "Scheme_Owner"; COMMENT ON TABLE "Schema_Name"."CHILD_STATUS" IS 'table comment'; COMMENT ON COLUMN "Schema_Name"."CHILD_STATUS"."CHILD_IDENTIFIER" IS 'column comment'; Regards Sud

Re: Encryption Options

2024-02-16 Thread sud
ckRest has that feature, using AES-256. Don't > know about BarMan.) > > Will try to verify these options. Considering these system processes 100's of millions of transactions, will these encryption add significant overhead? It would be great, if you can suggest some doc to follow, for implementing these. Not sure if the same would work for aurora too. Regards Sud

Encryption Options

2024-02-15 Thread sud
by encrypting, so it won't be visible in clear text to anybody and decrypting the same while needed and what would be the performance overhead of those options? Regards Sud

Partitioning options

2024-02-07 Thread sud
rtitioning strategy i.e range/hash (daily range partition by transaction_date and hash subpartition by customer_id)? OR Should we go for simple daily range partitioning on the transaction_date column? OR Range/list composite partitioning (range partition by transaction_date and list subpartition by customer_id)? Thanks and Regards Sud