Re: Question regarding how databases support atomicity

2024-05-07 Thread Siddharth Jain
quot; writes: > > On Friday, May 3, 2024, Siddharth Jain wrote: > >> The way I understand this is that if there is a failure in-between, we > >>> start undoing and reverting the previous operations one by one. > > > Not in PostgreSQL. All work performed is considered provisi

Re: Question regarding how databases support atomicity

2024-05-03 Thread Siddharth Jain
On Fri, May 3, 2024 at 8:00 PM Siddharth Jain wrote: > I am trying to sharpen my understanding of databases. Let's say there is > an operation foo as part of the public API that internally translates to > more than 1 operation - I am sure there are examples like this in postgres. >

Re: How do you optimize the disk IO when you cannot assume a file will start at a boundary then?

2024-02-22 Thread Siddharth Jain
Thanks Tomas On Thu, Feb 22, 2024 at 3:05 AM Tomas Vondra wrote: > On 2/22/24 02:22, Siddharth Jain wrote: > > Hi All, > > > > I understand the storage layer in databases goes to great lengths to > ensure: > > - a row does not cross a block boundary > > - re

How do you optimize the disk IO when you cannot assume a file will start at a boundary then?

2024-02-21 Thread Siddharth Jain
Hi All, I understand the storage layer in databases goes to great lengths to ensure: - a row does not cross a block boundary - read/writes/allocation happen in units of blocks etc. The motivation is that at the OS level, it reads and writes pages (blocks), not individual bytes. I am only

what happens if a failed transaction is not rolled back?

2023-04-24 Thread Siddharth Jain
Hi All, i understand when writing application code, we should rollback a transaction that fails to commit. this is typically done in the catch block of a try-catch exception handler. but what if the developer does not rollback the transaction? what happens in that case? note that i am not

Re: Question on SSI - Serializable Snapshot Isolation

2023-04-18 Thread Siddharth Jain
ok thanks tom. On Mon, Apr 17, 2023 at 2:39 PM Tom Lane wrote: > Siddharth Jain writes: > > When using SSI <https://wiki.postgresql.org/wiki/SSI>, lets say we have > two > > transactions T1 and T2 and there is a serialization conflict. Postgres > > knows whe

Question on SSI - Serializable Snapshot Isolation

2023-04-17 Thread Siddharth Jain
Hi All, When using SSI , lets say we have two transactions T1 and T2 and there is a serialization conflict. Postgres knows when one or the other transaction is doomed to fail [image: image.png] but will not raise serialization error until the transaction

Transaction Rollback errors

2023-04-11 Thread Siddharth Jain
Hi All, when my application (Node.js) receives a class 40 error: Class 40 — Transaction Rollback 4 transaction_rollback 40002 transaction_integrity_constraint_violation 40001 serialization_failure 40003 statement_completion_unknown 40P01 deadlock_detectedthen does it mean PG has already

What permissions are needed to drop a column from a table in postgres?

2023-04-02 Thread Siddharth Jain
Hi All, What permissions does a user need to be able to drop columns from a table in postgres? I did read this: https://www.postgresql.org/docs/14/sql-grant.html but could not find the answer. Thanks S.

Re: Question on creating keys on partitioned tables

2023-03-31 Thread Siddharth Jain
On Fri, Mar 31, 2023 at 9:07 AM Tom Lane wrote: > Siddharth Jain writes: > > I think the two are equivalent. If not, could you please explain why? > > Well, they're formally equivalent if you require there to be only one > X value per partition (ie, PARTITION BY LIST with onl

Re: Question on creating keys on partitioned tables

2023-03-31 Thread Siddharth Jain
Thanks Laurenz. I think the two are equivalent. If not, could you please explain why? On Fri, Mar 31, 2023 at 6:46 AM Laurenz Albe wrote: > On Thu, 2023-03-30 at 17:05 -0700, Siddharth Jain wrote: > > I have this question. Say I create a partitioned table on column X. > &g

Question on creating keys on partitioned tables

2023-03-30 Thread Siddharth Jain
Hi All, I have this question. Say I create a partitioned table on column X. Option 1: I add a primary key on (X,Y). Y is another column. Even though Y is a globally unique PK (global meaning it is unique across partitions, not just in one partition), Postgres does not allow me to create a PK on

Re: could not bind IPv4 address "127.0.0.1": Address already in use

2023-03-08 Thread Siddharth Jain
Thanks Tom. found the problem. On Tue, Mar 7, 2023 at 8:28 PM Tom Lane wrote: > Siddharth Jain writes: > > But when I try to start the server I get this: > > > 2023-03-07 17:16:43.228 PST [25925] LOG: could not bind IPv6 address > > "::1": Address already

could not bind IPv4 address "127.0.0.1": Address already in use

2023-03-07 Thread Siddharth Jain
Hi All, I am trying to run Postgres 14 on a Mac OS. I installed Postgres from EDB and ran initdb and it gave me this: ❯ initdb The files belonging to this database system will be owned by user "xxx". This user must also own the server process. The database cluster will be initialized with

Re: How does Postgres store a B-Tree on disk while using the OS file system?

2023-03-06 Thread Siddharth Jain
thanks Christophe. will try to go through it. its bit difficult to grasp. On Mon, Mar 6, 2023 at 5:08 PM Christophe Pettus wrote: > > > > On Mar 6, 2023, at 16:24, Siddharth Jain wrote: > > My question: How can it then store a B Tree on disk? I would think > storing a B

How does Postgres store a B-Tree on disk while using the OS file system?

2023-03-06 Thread Siddharth Jain
I am trying to sharpen my understanding of Postgres. As I understand, Postgres does not write directly to disk blocks. It uses the file system provided by the OS: https://dba.stackexchange.com/questions/80036/is-there-a-way-to-store-a-postgresql-database-directly-on-a-block-device-not-fi My

Comparing Postgres logical replication to MySQL

2023-02-26 Thread Siddharth Jain
Hi All, I am wondering if there is any article comparing Postgres logical replication to MySQL row based replication? https://dev.mysql.com/doc/refman/8.0/en/replication-sbr-rbr.html Are these two equivalent? If not, what are the differences? S.

Re: Does Postgres 14 have a query cache?

2023-02-18 Thread Siddharth Jain
Thanks all for the replies. Just wanted to confirm. On Sat, Feb 18, 2023 at 10:45 AM Steven Lembark wrote: > On Sat, 18 Feb 2023 12:43:42 -0600 > Ron wrote: > > > > I think the answer is no but wanted to confirm here. this is what > > > my best friend told me. > > There are caches for prepared

Re: How to use the BRIN index properly?

2023-02-08 Thread Siddharth Jain
23, at 13:17, Siddharth Jain wrote: > > > > As I explained in my question that is indeed our dilemma. Our insertion > order will not be equal to index order. i.e., referring to your response: > > > > > who's data is added in the same order as the key in the BRIN ind

Re: How to use the BRIN index properly?

2023-02-08 Thread Siddharth Jain
a log table where new records are always being appended > in "timestamp" order). > > It would also be great for history tables where you can pre-sort the data > by, for example, customer_id, and then put the BRIN on customer_id. > > On 2/8/23 13:58, Siddharth Jain wrote: &g

Re: How to use the BRIN index properly?

2023-02-08 Thread Siddharth Jain
our insertion order is of course != index order otherwise the question would have been trivial. we use postgres 14 On Wed, Feb 8, 2023 at 11:51 AM Siddharth Jain wrote: > Hello, > > We have large tables with billions of rows in them and want to take > advantage of the BRIN i

How to use the BRIN index properly?

2023-02-08 Thread Siddharth Jain
Hello, We have large tables with billions of rows in them and want to take advantage of the BRIN index on them. Issues we are facing: - as I understand, BRIN index is useful only if the data is stored in index order. As an example we want to create a composite BRIN index on 3 columns -

Re: FATAL: database "xxx" does not exist when it does

2023-02-01 Thread Siddharth Jain
> > > > using Postgres 14.4, I created a database as the postgres user: >> >> create database xxx; >> >> postgres=> \c xxx >> psql (13.9 (Debian 13.9-0+deb11u1), server 14.4) >> WARNING: psql major version 13, server major version 14. >> Some psql features might not work. >> SSL

Re: How to avoid having to run the GRANT command for newly added tables?

2022-11-23 Thread Siddharth Jain
Thanks Christophe. it works. On Wed, Nov 23, 2022 at 12:08 PM Christophe Pettus wrote: > > > > On Nov 23, 2022, at 12:06, Siddharth Jain wrote: > > Is there any way to accomplish what I want? Thanks. > > There is: > > > https://www.postgresql.org/docs/current/sql-alterdefaultprivileges.html >

How to avoid having to run the GRANT command for newly added tables?

2022-11-23 Thread Siddharth Jain
Hello - I have a Postgres 14 server. I created a database and then gave all privileges to tables in the database to a user as shown below: grant connect on database testdb to test_user; GRANT all ON ALL TABLES IN SCHEMA "public" TO test_user; I now verified that test_user is able to access an

Re: Some questions about Postgres

2022-11-06 Thread Siddharth Jain
Thanks Laurenz. On Fri, Nov 4, 2022 at 1:55 AM Laurenz Albe wrote: > On Thu, 2022-11-03 at 10:42 -0700, Christophe Pettus wrote: > > > On Nov 3, 2022, at 10:38, Siddharth Jain wrote: > > > I read an old article comparing MySQL to Postgres and wanted to get > answer

Re: Some questions about Postgres

2022-11-03 Thread Siddharth Jain
Thanks Christophe. Yes that is the article and I read the response as well. On Thu, Nov 3, 2022 at 10:42 AM Christophe Pettus wrote: > > > > On Nov 3, 2022, at 10:38, Siddharth Jain wrote: > > I read an old article comparing MySQL to Postgres and wanted to get > answers t

Some questions about Postgres

2022-11-03 Thread Siddharth Jain
Hi all, I am new to Postgres. I read an old article comparing MySQL to Postgres and wanted to get answers to following questions. All questions are w.r.t. Postgres 14: - do postgres secondary indexes point directly to tuples on disk? - does postgres use a separate process for each connection? -

How to load data from CSV into a table that has array types in its columns?

2022-10-26 Thread Siddharth Jain
Hello, Given a long list like this: 1,2 2,4 --> 2 appears once 7,9 8,9 5,3 2,5 --> note 2 appears twice I want to load it into this table: create table tbl ( id integer primary key, fids integer[] ) so we will have 2 -> [4,5] where 2 is id and [4,5] are the fids My actual dataset is very