Re: Subquery to select max(date) value

2019-02-12 Thread Andrew Gierth
> "Rich" == Rich Shepard writes: Rich> Will probably try DISTINCT ON, too, if that makes it simpler or Rich> faster. You want LATERAL. -- Andrew (irc:RhodiumToad)

Re: Subquery to select max(date) value

2019-02-12 Thread Rich Shepard
On Tue, 12 Feb 2019, Ken Tanzer wrote: If that's getting you what you want, then great and more power to you. It looks like you'll only get people who have a next_contact in your target window there. You might also consider something like this... Ken, I'll work with your example. This loo

Re: Getting wrong time using now()

2019-02-12 Thread Tom Lane
Om Prakash Jaiswal writes: > Create table service_record(Id into, time timestamp without time zone default > now()).Postgresql version 9.6.6, RHEL7.6 , when I am executing the query. I > am getting time 5:30hours behind current time. Please solve it Well, you probably ought to be using LOCALTIM

Re: Getting wrong time using now()

2019-02-12 Thread Adrian Klaver
On 2/12/19 3:36 PM, Om Prakash Jaiswal wrote: Create table service_record(Id into, time timestamp without time zone default now()). Postgresql version 9.6.6, RHEL7.6 , when I am executing the query. I am getting time 5:30hours behind current time. Please solve it Move clock back 5:30 hours:).

Re: Subquery to select max(date) value

2019-02-12 Thread Ken Tanzer
> > > Ken, > > Yes, cheers indeed. A bit of thinking and re-organizing resulted in a > working statement that's close to what I want: > > select (P.person_id, P.lname, P.fname, P.direct_phone, O.org_name, > (select max(A.next_contact))) > from People as P, Organizations as O, Activities as

Getting wrong time using now()

2019-02-12 Thread Om Prakash Jaiswal
Create table service_record(Id into, time timestamp without time zone default now()).Postgresql version 9.6.6, RHEL7.6 , when I am executing the query. I am getting time 5:30hours behind current time. Please solve it RegardsOm PrakashBangalore, India Sent from Yahoo Mail on Android

Re: Subquery to select max(date) value

2019-02-12 Thread Rich Shepard
On Tue, 12 Feb 2019, Ken Tanzer wrote: select (P.person_id, P.lname, P.fname, P.direct_phone, O.org_name, (select max(A.next_contact) from Activities as A WHERE p.person_id=A.person_id) FROM ... Ken, Yes, cheers indeed. A bit of thinking and re-organizing resulted in a working statement that

Re: Subquery to select max(date) value

2019-02-12 Thread Rich Shepard
On Tue, 12 Feb 2019, Adrian Klaver wrote: 'infinity' is the max date, so this is what you want? Adrian, Nope. When I went to make a cup of coffee I realized that I need the other date constraints (such as IS NOT NULL), too. I'm re-wording the statement to put everything in the correct order.

Re: Subquery to select max(date) value

2019-02-12 Thread Ken Tanzer
On Tue, Feb 12, 2019 at 2:48 PM Rich Shepard wrote: > On Tue, 12 Feb 2019, Rich Shepard wrote: > > > A.next_contact = (select (max(A.next_contact)) from Activities as A) > > Errata: > > The parentheses around the max aggregate are not necessary. > > A.next_contact now displays at the end of

Re: Subquery to select max(date) value

2019-02-12 Thread Adrian Klaver
On 2/12/19 2:48 PM, Rich Shepard wrote: On Tue, 12 Feb 2019, Rich Shepard wrote: A.next_contact = (select (max(A.next_contact)) from Activities as A) Errata: The parentheses around the max aggregate are not necessary. A.next_contact now displays at the end of each returned row as 'infi

Re: Subquery to select max(date) value

2019-02-12 Thread Matt Zagrabelny
Hey Rich, On Tue, Feb 12, 2019 at 4:24 PM Rich Shepard wrote: > The query is to return the latest next_contact date for each person. Using > the max() aggregate function and modeling the example of lo_temp on page 13 > of the rel. 10 manual I wrote this statement: > I use DISTINCT ON and ORDER

Re: Subquery to select max(date) value

2019-02-12 Thread Rich Shepard
On Tue, 12 Feb 2019, Rich Shepard wrote: A.next_contact = (select (max(A.next_contact)) from Activities as A) Errata: The parentheses around the max aggregate are not necessary. A.next_contact now displays at the end of each returned row as 'infinity'. Rich

Re: Subquery to select max(date) value

2019-02-12 Thread Rich Shepard
On Tue, 12 Feb 2019, Jeff Ross wrote: Try (select (max(A.next_contact) from A) Thanks, Jeff. The syntax accepted by psql is A.next_contact = (select (max(A.next_contact)) from Activities as A) but the date is not included in the output. The revised statement is now: select (P.person_id, P.ln

Re: Subquery to select max(date) value [RESOLVED]

2019-02-12 Thread Rich Shepard
On Tue, 12 Feb 2019, David G. Johnston wrote: You put the open parenthesis after the word select instead of before. A.next_contact = (SELECT max(A.next_contact) FROM A) David. Color me suitably embarrassed. Thank you, Rich

Re: Subquery to select max(date) value

2019-02-12 Thread David G. Johnston
On Tue, Feb 12, 2019 at 3:24 PM Rich Shepard wrote: > psql:next_contact_date.sql:7: ERROR: syntax error at or near "select" > LINE 4: A.next_contact = select (max(A.next_contact) from A) > ^ > and I fail to see what I've done incorrectly. You put the open pa

Subquery to select max(date) value

2019-02-12 Thread Rich Shepard
The query is to return the latest next_contact date for each person. Using the max() aggregate function and modeling the example of lo_temp on page 13 of the rel. 10 manual I wrote this statement: select (P.person_id, P.lname, P.fname, P.direct_phone, O.org_name, A.next_contact) from People as P

Re: Postgresql RDS DB Latency Chossing Hash join Plan

2019-02-12 Thread Michael Lewis
Did you update the stats by running ANALYZE on the tables involved, or perhaps the entire database on the 'Non prod Aurora RDS instance'? Can you share the two execution plans? *Michael Lewis | Software Engineer* *Entrata* *c: **619.370.8697 <619-370-8697>* On Tue, Feb 12, 2019 at 11:27 AM git

Temp tables and replication identities

2019-02-12 Thread Michael Lewis
I am curious about receiving an error on updating/inserting into a temp table when a replication for "all tables' is created in PG 10.6. Given temp tables are not replicated, it seems odd that an update fails unless a replication identity is defined. To reproduce, try the below code. Uncomment lin

Postgresql RDS DB Latency Chossing Hash join Plan

2019-02-12 Thread github kran
On Tue, Feb 12, 2019 at 7:07 AM github kran wrote: > > > On Mon, Feb 11, 2019 at 6:00 PM github kran wrote: > >> >> >> On Mon, Feb 11, 2019 at 3:29 PM Michael Lewis wrote: >> >>> Are default statistics target the same on both prod and AWS? Have you >>> analyzed all tables being used in this que

Re: pg_dump on a standby for a very active master

2019-02-12 Thread Stephen Frost
Greetings, * Arjun Ranade (ran...@nodalexchange.com) wrote: > Will barman automatically do a delta restore assuming the postgres server > is stopped and the old cluster exists at the same location it's restoring > to? I don't know if barman supports that today, it might. I do know that pgbackres

Re: pg_dump on a standby for a very active master

2019-02-12 Thread Arjun Ranade
Will barman automatically do a delta restore assuming the postgres server is stopped and the old cluster exists at the same location it's restoring to? On Tue, Feb 12, 2019 at 12:59 PM Stephen Frost wrote: > Greetings, > > * Arjun Ranade (ran...@nodalexchange.com) wrote: > > Yeah, that was one t

Re: pg_dump on a standby for a very active master

2019-02-12 Thread Stephen Frost
Greetings, * Arjun Ranade (ran...@nodalexchange.com) wrote: > Yeah, that was one thing I was planning to try. The other potential > solution is to use barman (we are using barman on all db servers including > standbys) to restore the latest backup to a VM and then take the pg_dump > from there.

Re: pg_dump on a standby for a very active master

2019-02-12 Thread Arjun Ranade
Yeah, that was one thing I was planning to try. The other potential solution is to use barman (we are using barman on all db servers including standbys) to restore the latest backup to a VM and then take the pg_dump from there. But I was hoping there would be a way in the settings to prevent such

RE: pg_dump on a standby for a very active master

2019-02-12 Thread Scot Kreienkamp
How about pausing replication while you’re running the backup? I have a mirror dedicated to backups, it pauses replication by cron job every night before the backup, then resumes midday after I’ve had enough time to find out if the backup was successful. Scot Kreienkamp |Senior Systems Engine

Re: Copy entire schema A to a different schema B

2019-02-12 Thread Tiffany Thang
Thanks Adrian! Tiff On Mon, Feb 11, 2019 at 11:53 AM Adrian Klaver wrote: > On 2/11/19 8:30 AM, Tiffany Thang wrote: > > Thanks Adrian and Ron. Sorry, I was not clear. What I'm trying to > > achieve was to dump the schema quickly and be able to restore a single > > or subset of objects from the

Re: Out of memory: Kill process nnnn (postmaster) score nn or sacrifice child

2019-02-12 Thread Adrian Klaver
On 2/12/19 8:20 AM, Vikas Sharma wrote: Hello All, I have a 4 node PostgreSQL 9.6 cluster with streaming replication.  we encounter today the Out of Memory  Error on the Master which resulted in All postres  processes restarted and cluster recovered itself. Please let me know the best way to

Re: postgresql v11.1 Segmentation fault: signal 11: by running SELECT... JIT Issue?

2019-02-12 Thread pabloa98
I tried. It works Thanks for the information. P On Mon, Jan 28, 2019, 7:28 PM Tom Lane wrote: > pabloa98 writes: > > I just migrated our databases from PostgreSQL version 9.6 to version > 11.1. > > We got a segmentation fault while running this query: > > > SELECT f_2110 as x FROM baseline_denu

Out of memory: Kill process nnnn (postmaster) score nn or sacrifice child

2019-02-12 Thread Vikas Sharma
Hello All, I have a 4 node PostgreSQL 9.6 cluster with streaming replication. we encounter today the Out of Memory Error on the Master which resulted in All postres processes restarted and cluster recovered itself. Please let me know the best way to diagnose this issue. The error seen in the

pg_dump on a standby for a very active master

2019-02-12 Thread Arjun Ranade
I have a Production machine which is having objects dropped/created/truncated at all hours of the day (Read: No zero activity window). I have multiple standbys (repmgr streaming replication) for this machine including a cascading standby. Each night, I am attempting to take a logical backup on th

Re: BDR 1.0: background worker wants to start that should not be there

2019-02-12 Thread Alvaro Aguayo Garcia-Rada
Hi. You have deleted the node from BDR setup, but you still have to delete it from the postgres logical replication: SELECT * FROM pg_replication_slots; SELECT pg_drop_replication_slot('YOURSLOT'); As a remark, based on my BDR experience, when your cluster has been damaged, your best option is

Re: postgresql v11.1 Segmentation fault: signal 11: by running SELECT... JIT Issue?

2019-02-12 Thread Justin Pryzby
On Mon, Nov 26, 2018 at 07:00:35PM -0800, Andres Freund wrote: > The fix is easy enough, just adding a > v_hoff = LLVMBuildZExt(b, v_hoff, LLVMInt32Type(), ""); > fixes the issue for me. On Tue, Jan 29, 2019 at 12:38:38AM -0800, pabloa98 wrote: > And perhaps should I modify this too? > If that

BDR 1.0: background worker wants to start that should not be there

2019-02-12 Thread Daniel Fink (PDF)
Hi all, After I used bdr.bdr_part_by_node_names(*p_nodes text[]*) and removed the nodes from bdr.bdr_nodes table I still get log errors about the nonexistent pg_replication_slot: < 2019-02-12 06:26:21.166 PST >LOG: starting background worker process "bdr (6208877715678412212,1,22576474,)->bd

Re: SV: Implementing pgaudit extension on Microsoft Windows

2019-02-12 Thread Tom Lane
Niels Jespersen writes: > Same result from > pgaudit.log = 'all' > in postgresql.conf and after both select pg_reload_conf(); and after service > restart. > No entries in the log from audit. Hm. I don't know much about pgaudit, but just from scanning its documentation, it doesn't seem like ther

Re: Blank, nullable date column rejected by psql

2019-02-12 Thread Rich Shepard
On Tue, 12 Feb 2019, Laurenz Albe wrote: If you insert a string into a "date" column, PostgreSQL will try to convert the string to a date with the type input function. The type input function fails on an empty string, since it cannot parse it into a valid "date" value. This also applies to the e

Re: Aurora Postgresql RDS DB Latency

2019-02-12 Thread github kran
On Mon, Feb 11, 2019 at 6:00 PM github kran wrote: > > > On Mon, Feb 11, 2019 at 3:29 PM Michael Lewis wrote: > >> Are default statistics target the same on both prod and AWS? Have you >> analyzed all tables being used in this query to ensure stats are up proper? >> If the optimizer is choosing

Re: Implementing pgaudit extension on Microsoft Windows

2019-02-12 Thread Pavel Stehule
út 12. 2. 2019 v 10:34 odesílatel Niels Jespersen napsal: > Same result from > > > > pgaudit.log = 'all' > > > > in postgresql.conf and after both select pg_reload_conf(); and after > service restart. > > > > No entries in the log from audit. > It is strange - can you try same setup on linux?

SV: Implementing pgaudit extension on Microsoft Windows

2019-02-12 Thread Niels Jespersen
Same result from pgaudit.log = 'all' in postgresql.conf and after both select pg_reload_conf(); and after service restart. No entries in the log from audit. Regards Niels Fra: Pavel Stehule Sendt: 12. februar 2019 09:01 Til: Niels Jespersen Cc: Tom Lane ; pgsql-general@lists.postgresql.

Re: Blank, nullable date column rejected by psql

2019-02-12 Thread Laurenz Albe
Rich Shepard wrote: > Now I know to replace no dates with null I'll do so but I'm curious why this > is needed. NULL is a special "unknown" value in SQL. You can use it for all data types to signal that a value is unknown or not available. If you insert a string into a "date" column, PostgreSQL

Re: Implementing pgaudit extension on Microsoft Windows

2019-02-12 Thread Pavel Stehule
út 12. 2. 2019 v 8:59 odesílatel Pavel Stehule napsal: > > > út 12. 2. 2019 v 8:57 odesílatel Niels Jespersen napsal: > >> Thanks Tom >> >> alter system set pgaudit.log = 'all'; -- Works, it results in 2019-02-12 >> 08:51:49.109 CET [13560] LOG: parameter "pgaudit.log" changed to "all" >> after

Re: Implementing pgaudit extension on Microsoft Windows

2019-02-12 Thread Pavel Stehule
út 12. 2. 2019 v 8:57 odesílatel Niels Jespersen napsal: > Thanks Tom > > alter system set pgaudit.log = 'all'; -- Works, it results in 2019-02-12 > 08:51:49.109 CET [13560] LOG: parameter "pgaudit.log" changed to "all" > after select pg_reload_conf(); > alter system set pgaudit.logx = 'all'; --