Re: RowLock and multiple transactions

2024-02-14 Thread Laurenz Albe
On Wed, 2024-02-14 at 23:52 +0100, Hannes Erven wrote: > when "SELECT .. WHERE .. FOR NO KEY UPDATE" is used synchronize access, > and the transaction holding the lock completes, how does PostgreSQL > decide /which one/ of multiple waiting transactions will the lock be > granted to next? > >

Re: How to do faster DML

2024-02-14 Thread David G. Johnston
On Tuesday, February 13, 2024, veem v wrote: > > float data types rather than numeric. This will give better performance. > Only use an inexact floating-point data type if you truly understand what you are getting yourself into. Quickly getting the wrong answer isn’t tolerable solution. David

Re: How to do faster DML

2024-02-14 Thread Ron Johnson
On Wed, Feb 14, 2024 at 11:58 PM veem v wrote: > > > On Thu, 15 Feb 2024 at 00:43, Adrian Klaver > wrote: > >> It depends: >> >> https://www.postgresql.org/docs/current/sql-altertable.html >> >> "Adding a column with a volatile DEFAULT or changing the type of an >> existing column will require

Re: How to do faster DML

2024-02-14 Thread veem v
On Thu, 15 Feb 2024 at 00:43, Adrian Klaver wrote: > It depends: > > https://www.postgresql.org/docs/current/sql-altertable.html > > "Adding a column with a volatile DEFAULT or changing the type of an > existing column will require the entire table and its indexes to be > rewritten. As an

Re: Accessing parameters of a prepared query inside an FDW

2024-02-14 Thread David G. Johnston
On Wednesday, February 14, 2024, Adam Fletcher wrote: > > > Is it possible to get the parameterized prepared query inside an FDW such > that it can be prepared/bind'd/execute'd on the receiving end of the FDW? > > For example, if I `PREPARE stmt(int) AS SELECT * from fdwrapped_tbl where > pk =

Accessing parameters of a prepared query inside an FDW

2024-02-14 Thread Adam Fletcher
Hi Folks, Is it possible to get the parameterized prepared query inside an FDW such that it can be prepared/bind'd/execute'd on the receiving end of the FDW? For example, if I `PREPARE stmt(int) AS SELECT * from fdwrapped_tbl where pk = $1;` then `execute stmt(1);` I want my FDW be aware that

RowLock and multiple transactions

2024-02-14 Thread Hannes Erven
Hi, when "SELECT .. WHERE .. FOR NO KEY UPDATE" is used synchronize access, and the transaction holding the lock completes, how does PostgreSQL decide /which one/ of multiple waiting transactions will the lock be granted to next? In my testing (on Ubuntu 16.1-1.pgdg20.04+1, 64bit) with a

Re: Query regarding function cleanup in extension upgrade path

2024-02-14 Thread Tom Lane
Ayush Vatsa writes: > Just two follow up queries regarding this - > 1. Suppose I created a new version 1.1 in which I reduce the C function to > throw an error then ship it, will users get the .c latest file immediately > and their old function will throw error but they have to use ALTER >

Re: PITR

2024-02-14 Thread Greg Sabino Mullane
On Wed, Feb 14, 2024 at 1:39 PM Yongye Serkfem wrote: > I checked the Postgresql.conf file and can't find the > appropriate parameter to set the target time. > It is set inside the postgresql.conf file. Unless you have modified it, there is a section in there called "Recovery Target" which has

Re: PITR

2024-02-14 Thread Ron Johnson
On Wed, Feb 14, 2024 at 1:39 PM Yongye Serkfem wrote: > Hi, > I hope you are all doing well. I am trying to do PITR on Postgresql v12. > Now that the recovery.conf file is not available in this version, where > should I set the recovery_target_time? I checked the Postgresql.conf file > and can't

Re: How to do faster DML

2024-02-14 Thread Adrian Klaver
On 2/14/24 10:11 AM, veem v wrote: On Wed, 14 Feb, 2024, 10:30 am Ron Johnson, wrote: On Tue, Feb 13, 2024 at 4:17 PM veem v wrote: [sni[] One question here, if we have defined one column as a fixed length data type "integer" and slowly we noticed the

PITR

2024-02-14 Thread Yongye Serkfem
Hi, I hope you are all doing well. I am trying to do PITR on Postgresql v12. Now that the recovery.conf file is not available in this version, where should I set the recovery_target_time? I checked the Postgresql.conf file and can't find the appropriate parameter to set the target time. I'm

Re: How to do faster DML

2024-02-14 Thread veem v
On Wed, 14 Feb, 2024, 10:30 am Ron Johnson, wrote: > On Tue, Feb 13, 2024 at 4:17 PM veem v wrote: > [sni[] > >> One question here, if we have defined one column as a fixed length data >> type "integer" and slowly we noticed the length of data keeps increasing >> (in case of a sequence

Re: Query regarding function cleanup in extension upgrade path

2024-02-14 Thread Ayush Vatsa
Hi Tom thanks for the answer, Just two follow up queries regarding this - 1. Suppose I created a new version 1.1 in which I reduce the C function to throw an error then ship it, will users get the .c latest file immediately and their old function will throw error but they have to use ALTER

Re: PostgreSQL DB in prod, test, debug

2024-02-14 Thread Adrian Klaver
On 2/14/24 02:38, Erik Wienhold wrote: On 2024-02-14 10:59 +0100, Simon Connah wrote: The database schema should be defined by migration scripts that you also check into version control with the rest of your application sources. Some people also prefer a separate repository just for the

Re: Query regarding function cleanup in extension upgrade path

2024-02-14 Thread Tom Lane
Ayush Vatsa writes: > To ask the question let me give a hypothetical example:- > Suppose we have an extension named xyz with version 1.0. It has > xyz--1.0.sql and xyz.c file. I have declared a function named fun() in the > xyz--1.0.sql file and its definition in the xyz.c file. > Now I want to

Query regarding function cleanup in extension upgrade path

2024-02-14 Thread Ayush Vatsa
Hi PostgreSQL Community, I have been working on a few extensions but got confused in the upgrade scenario. To ask the question let me give a hypothetical example:- Suppose we have an extension named xyz with version 1.0. It has xyz--1.0.sql and xyz.c file. I have declared a function named fun() in

Re: Postgres pg_cron extension

2024-02-14 Thread Ron Johnson
On Wed, Feb 14, 2024 at 10:23 AM Greg Sabino Mullane wrote: > Yes, definitely the wrong forum. RDS is not Postgres, and "parameter > groups" is an Amazon thing. A quick web search would seem to indicate that > the default group is replaced by the custom one, rather than enhancing it. > But

Re: How should we design our tables and indexes

2024-02-14 Thread Greg Sabino Mullane
On Tue, Feb 13, 2024 at 2:26 PM veem v wrote: > Can the optimizer, only scan the TABLE1 using ACCESS criteria " > TABLE1.MID in ()" or "TABLE1.CID in ()" which will be catered by > two different index i.e one index on column "MID" and other on column "CID"? > Yes: greg=# create table

Re: Postgres pg_cron extension

2024-02-14 Thread Greg Sabino Mullane
Yes, definitely the wrong forum. RDS is not Postgres, and "parameter groups" is an Amazon thing. A quick web search would seem to indicate that the default group is replaced by the custom one, rather than enhancing it. But really, this is a simple "try it and see" sort of task.

Re: Two test failures on v16 (compared to v14)

2024-02-14 Thread Tom Lane
Dominique Devienne writes: > Just an FYI. Running the same test suite against V16 triggered two failures. > ... > Second, a LO test failed to open a given OID. > The test starts a read-only transaction, then tries a loOpen(oid, > INV_WRITE), > but does only a loRead(). Now in v16, the loOpen

Re: Using a Conversion Table

2024-02-14 Thread Greg Sabino Mullane
> > "Fiscal year" double precision, > This column is an INTEGER in your other table, so your schema is not even internally consistent! Try to use TEXT, INT, DATE and TIMESTAMPTZ whenever possible, with NUMERIC as needed for things with a precision. See:

Re: Using a Conversion Table

2024-02-14 Thread David G. Johnston
On Wednesday, February 14, 2024, Anthony Apollis wrote: > > *Conversion Table :* > > > CREATE TABLE IF NOT EXISTS dim."IMETA_Master_Currency_Data_TA_BR" > ( > "Currency" character varying(255) COLLATE pg_catalog."default", > "Currency name" character varying(255) COLLATE

Using a Conversion Table

2024-02-14 Thread Anthony Apollis
*I am trying to convert a column from ZAR Column " Amount_in_Company_Code_Currency" " to USD.* Table: CREATE TABLE IF NOT EXISTS system."IMETA_ZTRB_MP$F_ZTBR_TA_BW2" ( "Company_Code" character varying(255) COLLATE pg_catalog."default", "Posting_Period" integer, "Fiscal_Year" integer,

Re: PostgreSQL DB in prod, test, debug

2024-02-14 Thread Simon Connah
On Wednesday, 14 February 2024 at 10:38, Erik Wienhold wrote: > > > On 2024-02-14 10:59 +0100, Simon Connah wrote: > > > This project uses Python 3.12, Flask, psycopg3 and PostgreSQL 15. > > > > This is probably a stupid question so I apologies in advance. > > > > I'm building a

Re: PostgreSQL DB in prod, test, debug

2024-02-14 Thread Simon Connah
On Wednesday, 14 February 2024 at 10:25, Daniel Gustafsson wrote: > > > > On 14 Feb 2024, at 10:59, Simon Connah simon.n.con...@protonmail.com wrote: > > > This is probably a stupid question so I apologies in advance. > > > There is no such thing. > > > What I think is the best way

Two test failures on v16 (compared to v14)

2024-02-14 Thread Dominique Devienne
Just an FYI. Running the same test suite against V16 triggered two failures. First, a test of getting the direct members of a role failed. Returned one more role. The role that created the introspected role. That's the new CREATEROLE semantic, which adds the role creator as a direct member of the

Re: PostgreSQL DB in prod, test, debug

2024-02-14 Thread Erik Wienhold
On 2024-02-14 10:59 +0100, Simon Connah wrote: > This project uses Python 3.12, Flask, psycopg3 and PostgreSQL 15. > > This is probably a stupid question so I apologies in advance. > > I'm building a website using PostgreSQL and since I've just been doing > some dev work on it I've just manually

Postgres pg_cron extension

2024-02-14 Thread arun chirappurath
Dear all, I am trying to enable pg_cron extension in RDS postgres and I got to know it will be enabled only in custom parameter group..it can't be enabled in default one. 1. Suppose if we create a custom group for existing postgres 14 databases,will all the existing parameters in default group

Re: PostgreSQL DB in prod, test, debug

2024-02-14 Thread Daniel Gustafsson
> On 14 Feb 2024, at 10:59, Simon Connah wrote: > This is probably a stupid question so I apologies in advance. There is no such thing. > What I think is the best way to do this is to do a pg_dump of the database > (using the --schema-only flag) and then load it into a test only database >

PostgreSQL DB in prod, test, debug

2024-02-14 Thread Simon Connah
Hi, This project uses Python 3.12, Flask, psycopg3 and PostgreSQL 15. This is probably a stupid question so I apologies in advance. I'm building a website using PostgreSQL and since I've just been doing some dev work on it I've just manually played around with the database if I needed new