Re: [GENERAL] slow performance of array_agg after upgrade from 9.2 to 9.5

2016-10-27 Thread Pavel Stehule
2016-10-26 15:06 GMT+02:00 jaroet : > Internally we upgraded from 9.2 to 9.5 en we had defined an median > function. > This became about 7 to 8 times slower using the same functions. > > They are defined like this: > > > CREATE OR REPLACE FUNCTION public._final_median(anyarray) > RETURNS double

[GENERAL] parallel query and row-level security?

2016-10-27 Thread Karl Czajkowski
Hi, I am struggling to find information on how the new parallel query features intersect with row-level security. I am wondering whether this is expected to work at this time? My cursory experiments indicate that we can get a parallel plan when querying as the table owner or superuser but not whe

Re: [GENERAL] Save query results to new table [RESOLVED]

2016-10-27 Thread Rich Shepard
On Thu, 27 Oct 2016, John R Pierce wrote: CREATE TABLE newtable AS SELECT ... https://www.postgresql.org/docs/9.5/static/sql-createtableas.html Thank you, John. Much appreciated, Rich -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscripti

Re: [GENERAL] Save query results to new table

2016-10-27 Thread John R Pierce
On 10/27/2016 4:57 PM, Rich Shepard wrote: It's been several years since I worked with postgres so I tried searching the web for the correct syntax to save query results to a new table, but without results. I'm running postgresql-9.5.4 here. The query extracts 28162 rows from a table of 122

[GENERAL] Save query results to new table

2016-10-27 Thread Rich Shepard
It's been several years since I worked with postgres so I tried searching the web for the correct syntax to save query results to a new table, but without results. I'm running postgresql-9.5.4 here. The query extracts 28162 rows from a table of 122365 rows. I thought 'save table as' would do

[GENERAL] slow performance of array_agg after upgrade from 9.2 to 9.5

2016-10-27 Thread jaroet
Internally we upgraded from 9.2 to 9.5 en we had defined an median function. This became about 7 to 8 times slower using the same functions. They are defined like this: CREATE OR REPLACE FUNCTION public._final_median(anyarray) RETURNS double precision LANGUAGE sql AS $body$ WITH q AS (

Re: [GENERAL] The consequenses of interrupted vacuum

2016-10-27 Thread Bill Moran
On Thu, 27 Oct 2016 10:44:03 -0400 Tom Lane wrote: > > I'm asking for cases of large tables where autovacuum frequently gets > > interrupted. I'm trying to understand if the partial runs are at least > > making _some_ progress so the next vacuum has less to do, or if this is > > a serious problem

[GENERAL] restore/pg_dump only one id, with relation (cascade)

2016-10-27 Thread Hans Schou
Hi We have a system with several users. Sometimes one of the users make a mistake with his data and want to restore, like he want to do an undo. Only one user should be restored, not all users. I work as sysadm so I can not change the system, but has to solve the task at this level. My approach

Re: [GENERAL] libpq heartbeat

2016-10-27 Thread Merlin Moncure
On Thu, Oct 27, 2016 at 12:45 PM, Francisco Olarte wrote: > Merlin: > > On Thu, Oct 27, 2016 at 7:29 PM, Merlin Moncure wrote: >> On Thu, Oct 27, 2016 at 11:18 AM, Francisco Olarte >> wrote: >>> It is, but handling them is not easy, and you have to deal with things >>> like DoS which are not tri

Re: [GENERAL] libpq heartbeat

2016-10-27 Thread Marcin Giedz
Thank you all for your feedback. I've checked both server and client side and : a) libpq by default enables keepalive b) in postgresql.conf tcp_keepalives_idle=0 (default setting) means - apply system default Is there any chance that it's NOT fired on RHEL7 acting as SQL server for some reas

Re: [GENERAL] libpq heartbeat

2016-10-27 Thread Francisco Olarte
Merlin: On Thu, Oct 27, 2016 at 7:29 PM, Merlin Moncure wrote: > On Thu, Oct 27, 2016 at 11:18 AM, Francisco Olarte > wrote: >> It is, but handling them is not easy, and you have to deal with things >> like DoS which are not trivial on the server ( as it is a heavy >> service ). It can be done,

Re: [GENERAL] Escape variable

2016-10-27 Thread Adrian Klaver
On 10/27/2016 08:57 AM, Jaime Rivera wrote: Hello, I've been looking for a way to escape a variable inside a plpgsql stored procedure just like E works with constants. For example : * select E'Se recibi\u00f3 a \n ci\u00f3n.' * Returns: /*Se recibió a */ /* ción.*/ Something like?: DO $

Re: [GENERAL] libpq heartbeat

2016-10-27 Thread Merlin Moncure
On Thu, Oct 27, 2016 at 11:18 AM, Francisco Olarte wrote: > Merlin: > > On Thu, Oct 27, 2016 at 6:10 PM, Merlin Moncure wrote: >> On Thu, Oct 27, 2016 at 10:01 AM, Francisco Olarte >> wrote: >>> And I'd like to point libpq sessions does not sound to be the best >>> kind of traffic across a firew

Re: [GENERAL] libpq heartbeat

2016-10-27 Thread Francisco Olarte
Tom: On Thu, Oct 27, 2016 at 6:32 PM, Tom Lane wrote: > Francisco Olarte writes: >> Isn't this a server setting, and so going to affect every connection, > Yes, Ok, just checking. > but there are equivalent libpq parameters for firing heartbeat > pings from the client side. Those are per-conn

[GENERAL] How to hint two columns IS NOT DISTINCT FROM each other in a join

2016-10-27 Thread Kim Rose Carlsen
Hi I was wondering if there is a way to hint that two columns in two different tables IS NOT DISTINCT FROM each other. So that the optimizer may assume if table_a.key = 'test' THEN table_b.key = 'test' . The equals operator already does this but it does not handle NULLS very well (or not at

Re: [GENERAL] libpq heartbeat

2016-10-27 Thread Tom Lane
Francisco Olarte writes: > On Thu, Oct 27, 2016 at 5:01 PM, hubert depesz lubaczewski > wrote: >> On Thu, Oct 27, 2016 at 04:43:55PM +0200, Marcin Giedz wrote: >>> I'm wondering if there is any natural implementation of heartbeats in >>> libpq library? >> check tcp_keepalives_* in postgresql.con

Re: [GENERAL] libpq heartbeat

2016-10-27 Thread Francisco Olarte
Merlin: On Thu, Oct 27, 2016 at 6:10 PM, Merlin Moncure wrote: > On Thu, Oct 27, 2016 at 10:01 AM, Francisco Olarte > wrote: >> And I'd like to point libpq sessions does not sound to be the best >> kind of traffic across a firewall, not a good service / protocol to >> expose. > meh -- it's perf

Re: [GENERAL] libpq heartbeat

2016-10-27 Thread Merlin Moncure
On Thu, Oct 27, 2016 at 10:01 AM, Francisco Olarte wrote: > And I'd like to point libpq sessions does not sound to be the best > kind of traffic across a firewall, not a good service / protocol to > expose. meh -- it's perfectly fine to expose postgres to the internet as long as you've handled th

[GENERAL] Escape variable

2016-10-27 Thread Jaime Rivera
Hello, I've been looking for a way to escape a variable inside a plpgsql stored procedure just like E works with constants. For example : * select E'Se recibi\u00f3 a \n ci\u00f3n.' * Returns: *Se recibió a * * ción.* Thanks Jaime

Re: [GENERAL] libpq heartbeat

2016-10-27 Thread Francisco Olarte
On Thu, Oct 27, 2016 at 5:01 PM, hubert depesz lubaczewski wrote: > On Thu, Oct 27, 2016 at 04:43:55PM +0200, Marcin Giedz wrote: ... >> I'm wondering if there is any natural implementation of heartbeats in >> libpq library? ... > check tcp_keepalives_* in postgresql.conf Isn't this a server set

Re: [GENERAL] libpq heartbeat

2016-10-27 Thread Francisco Olarte
Hi Marcin: On Thu, Oct 27, 2016 at 4:43 PM, Marcin Giedz wrote: > I'm wondering if there is any natural implementation of heartbeats in libpq > library? We've been facing specially in firewall env occasionally session > drops between client and server. Extending session timeout directly on > fire

Re: [GENERAL] Remove Standby (SLAVE) from Primary (MASTER) - Postgres9.1

2016-10-27 Thread Melvin Davidson
On Thu, Oct 27, 2016 at 10:27 AM, Scott Mead wrote: > > > On 10/27/16 10:12 AM, Joanna Xu wrote: > > We need to keep the data as it is so remving data fold is not feasible. > > If I run "pg_ctl promote" on the slave to make it fail over, this will > break the replication and then clean up the con

Re: [GENERAL] libpq heartbeat

2016-10-27 Thread hubert depesz lubaczewski
On Thu, Oct 27, 2016 at 04:43:55PM +0200, Marcin Giedz wrote: > Hello all > > I'm wondering if there is any natural implementation of heartbeats in > libpq library? We've been facing specially in firewall env > occasionally session drops between client and server. Extending > session timeout dire

Re: [GENERAL] The consequenses of interrupted vacuum

2016-10-27 Thread Tom Lane
Bill Moran writes: > Does interrupting a VACUUM (not FULL) rollback all the work it has done > so far, or is the work done on a page by page basis such that at least > some of the pages in the table have been vacuumed? Depends on how big the table is, how many dead tuples there are, and what main

[GENERAL] libpq heartbeat

2016-10-27 Thread Marcin Giedz
Hello all I'm wondering if there is any natural implementation of heartbeats in libpq library? We've been facing specially in firewall env occasionally session drops between client and server. Extending session timeout directly on firewalls is not possible (company rules). Perhaps there is suc

Re: [GENERAL] Remove Standby (SLAVE) from Primary (MASTER) - Postgres9.1

2016-10-27 Thread Scott Mead
On 10/27/16 10:12 AM, Joanna Xu wrote: > We need to keep the data as it is so remving data fold is not feasible. > If I run "pg_ctl promote" on the slave to make it fail over, this will break > the replication and then clean up the configuration related to replication. > Any feedback? Just to

[GENERAL] The consequenses of interrupted vacuum

2016-10-27 Thread Bill Moran
Very specific question: Does interrupting a VACUUM (not FULL) rollback all the work it has done so far, or is the work done on a page by page basis such that at least some of the pages in the table have been vacuumed? I'm asking for cases of large tables where autovacuum frequently gets interrupt

Re: [GENERAL] Remove Standby (SLAVE) from Primary (MASTER) - Postgres9.1

2016-10-27 Thread Joanna Xu
We need to keep the data as it is so remving data fold is not feasible. If I run "pg_ctl promote" on the slave to make it fail over, this will break the replication and then clean up the configuration related to replication. Any feedback? Thanks, Joanna -Original Message- From: Adrian

Re: [GENERAL] Remove Standby (SLAVE) from Primary (MASTER) - Postgres9.1

2016-10-27 Thread Joanna Xu
Here is the current recovery.conf on slave. Does the trigger_file need to be changed? If it does, can you give me an example? # Note that recovery.conf must be in $PGDATA directory. # Specifies whether to start the server as a standby. In streaming replication, # this parameter must to be set to

Re: [GENERAL] Locking question

2016-10-27 Thread Kevin Grittner
On Thu, Oct 27, 2016 at 1:37 AM, Frank Millman wrote: > As mentioned previously, I am trying to avoid using PostgreSQL-specific > techniques, as I need to support sqlite3 and SQL Server as well. The SERIALIZABLE transaction isolation level is portable. It it part of the SQL standard (and has be

Re: [GENERAL] Passing NULL values in dblink function call

2016-10-27 Thread Jaisingkar, Piyush
Thanks, that worked. I have another problem in this code, can you help me solve it, Please see the two highlighted line of codes, In the remote function im returning the table containing three columns. This works fine as I tried calling the remote function in a single explicit query. But when I

[GENERAL] Passing NULL values in dblink function call

2016-10-27 Thread Jaisingkar, Piyush
Hello, I have created two functions on two different databases connected them using dblink. FOLLOWING IS THE LOCAL FUNCTION: CREATE OR REPLACE FUNCTION chdb.dblink_onlocal() RETURNS (par1 varchar,par2 varchar,par3 varchar) AS $$ DECLARE query varchar; r record; BEGIN PERFORM dblink_connect_u(