Re: [GENERAL] Turning slave into a master - PostgreSQL 9.2

2016-10-31 Thread Patrick B
If I change recovery.conf: recovery_target_time = '2016-10-30 02:24:40' I get error: FATAL: requested recovery stop point is before consistent recovery point

Re: [GENERAL] Turning slave into a master - PostgreSQL 9.2

2016-10-31 Thread Patrick B
I actually want to restore in a point of time. Don't want to recovery_target_timeline = 'latest' How can I stipulate a date? Thanks 2016-11-01 11:59 GMT+13:00 Patrick B : > > > 2016-11-01 10:33 GMT+13:00 David G. Johnston : > >> On Mon, Oct 31, 2016 at 1:46 PM, Patrick B >> wrote: >> >>> Hi g

Re: [GENERAL] initdb createuser commands

2016-10-31 Thread Adrian Klaver
On 10/31/2016 05:15 PM, Samuel Williams wrote: > Daniel, your reply is awesome :) I love the historical context and it > brings much clarity to the discussion! > > It's now understandable why the commands were named the way they were. > > I'm surprised that distros are making their own commands f

Re: [GENERAL] initdb createuser commands

2016-10-31 Thread Samuel Williams
Daniel, your reply is awesome :) I love the historical context and it brings much clarity to the discussion! It's now understandable why the commands were named the way they were. I'm surprised that distros are making their own commands for postgres.. isn't that a bit invasive? On 1 November 2

Re: [GENERAL] Way to quickly detect if database tables/columns/etc. were modified?

2016-10-31 Thread Melvin Davidson
On Mon, Oct 31, 2016 at 4:41 PM, Evan Martin wrote: > On 31/10/2016 8:26 PM, Melvin Davidson wrote: > > I have tried using an event trigger to detect table creation (ie: > tg_event_audit_all ) however, that does not parse the schema_name and objid > as does pg_event_trigger_dropped_objects(), so

Re: [GENERAL] Turning slave into a master - PostgreSQL 9.2

2016-10-31 Thread Patrick B
2016-11-01 10:33 GMT+13:00 David G. Johnston : > On Mon, Oct 31, 2016 at 1:46 PM, Patrick B > wrote: > >> Hi guys, >> >> I got a test server, let's call it test01. >> >> The test01 has a basebackup from the master. >> I want to turn test01 into a master. It doesn't need to catch up with the >> wa

Re: [GENERAL] Turning slave into a master - PostgreSQL 9.2

2016-10-31 Thread David G. Johnston
On Mon, Oct 31, 2016 at 1:46 PM, Patrick B wrote: > Hi guys, > > I got a test server, let's call it test01. > > The test01 has a basebackup from the master. > I want to turn test01 into a master. It doesn't need to catch up with the > wal_files, because I don't need it to be up-to-date. > > So wh

[GENERAL] Turning slave into a master - PostgreSQL 9.2

2016-10-31 Thread Patrick B
Hi guys, I got a test server, let's call it test01. The test01 has a basebackup from the master. I want to turn test01 into a master. It doesn't need to catch up with the wal_files, because I don't need it to be up-to-date. So what I did is: - Replaced /var/lib/pgsql/9.2/data/ with the baseback

Re: [GENERAL] Way to quickly detect if database tables/columns/etc. were modified?

2016-10-31 Thread Evan Martin
On 31/10/2016 8:26 PM, Melvin Davidson wrote: I have tried using an event trigger to detect table creation (ie: tg_event_audit_all ) however, that does not parse the schema_name and objid as does pg_event_trigger_dropped_objects(), so I am not sure that is a practical way to audit. Event trig

Re: [GENERAL] Checking Postgres Streaming replication delay

2016-10-31 Thread Patrick B
2016-10-31 15:54 GMT+13:00 Venkata B Nagothi : > > On Mon, Oct 31, 2016 at 11:57 AM, Patrick B > wrote: > >> Hi guys, >> >> I'm using this query to measure the delay between a Master and a >> Streaming Replication Slave server, using PostgreSQL 9.2. >> >> SELECT >>> pg_last_xlog_receive_location(

Re: [GENERAL] Way to quickly detect if database tables/columns/etc. were modified?

2016-10-31 Thread Melvin Davidson
On Mon, Oct 31, 2016 at 2:09 PM, John DeSoi wrote: > > > On Oct 31, 2016, at 8:14 AM, Melvin Davidson > wrote: > > > > That would certainly work, but the problem is, that trigger would have > to be created for every table in the database. > > When you have more than a couple dozen tables, as in

Re: [GENERAL] RPM Package of PostgreSQL 9.6.1 for CentOS

2016-10-31 Thread John R Pierce
On 10/31/2016 11:52 AM, Igal @ Lucee.org wrote: I see the package for 9.6.0 at https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/ pgdg-centos96-9.6-3.noarch.rpm Should there be one for 9.6.1? thats the yum.repos.d stuff for the 9.6 repository, it doesn't need updating for sub relea

[GENERAL] RPM Package of PostgreSQL 9.6.1 for CentOS

2016-10-31 Thread Igal @ Lucee.org
Hi, I see the package for 9.6.0 at https://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/ pgdg-centos96-9.6-3.noarch.rpm Should there be one for 9.6.1? When I try to install postgresql96-9.6.1-1PGDG.rhel7.x86_64.rpm I get dependency errors, so I'm looking for a package like the one above

Re: [GENERAL] Way to quickly detect if database tables/columns/etc. were modified?

2016-10-31 Thread John DeSoi
> On Oct 31, 2016, at 8:14 AM, Melvin Davidson wrote: > > That would certainly work, but the problem is, that trigger would have to be > created for every table in the database. > When you have more than a couple dozen tables, as in hundreds, it becsmes a > huge undertaking. Unless I'm misun

Re: [GENERAL] Rows are repeating by the trigger function

2016-10-31 Thread Adrian Klaver
On 10/31/2016 10:02 AM, Kiran wrote: Dear Adrian and Alban, Thanks for the suggestions. I revisited the entire tables, triggers related to the tables. I did not find anything strange. But, I removed all the rows from the* *cf_user_question_link and inserted relevant rows into the table from *cf_

Re: [GENERAL] initdb createuser commands

2016-10-31 Thread Daniel Verite
Samuel Williams wrote: > John - that's an interesting example. If it's that easy, why isn't > that the approach given in tutorials and other documentation? What was > the motivation for the createuser command? initdb, createdb and createuser existed even before Postgres adopted SQL, back

Re: [GENERAL] How to optimize SELECT query with multiple CASE statements?

2016-10-31 Thread Alexander Farber
Ah, thanks - I've got that with JOINing via CASE now... On Mon, Oct 31, 2016 at 5:50 PM, Geoff Winkless wrote: > especially since (as I said in the last paragraph of my email), you > can remove all of the CASEs except the hand/score ones by just JOINing > the other tables via a CASE anyway. >

Re: [GENERAL] Rows are repeating by the trigger function

2016-10-31 Thread Kiran
Dear Adrian and Alban, Thanks for the suggestions. I revisited the entire tables, triggers related to the tables. I did not find anything strange. But, I removed all the rows from the cf_user_question_link and inserted relevant rows into the table from *cf_question*. Also, I recreated the functi

Re: [GENERAL] How to optimize SELECT query with multiple CASE statements?

2016-10-31 Thread Geoff Winkless
On 31 October 2016 at 15:46, Alexander Farber wrote: > do you mean, instead of having player1, player2 columns in the words_games > table (as in my current schema > https://gist.github.com/afarber/c40b9fc5447335db7d24 ) - I should move the > player stuff (uid, hand, score) to a separate table and

Re: [GENERAL] How to optimize SELECT query with multiple CASE statements?

2016-10-31 Thread David G. Johnston
On Mon, Oct 31, 2016 at 5:53 AM, Alexander Farber < alexander.far...@gmail.com> wrote: > Good afternoon, > > is it please posible to optimize the following SQL query with numerous > CASE statements (on same condition!) without switching to PL/pgSQL? > > SELECT > g.gid, > EXTRAC

[GENERAL] Validity of using the test_decoding plugin for production?

2016-10-31 Thread Joshua Kehn
Hi all, I'm considering using the test_decoding[1] plugin in conjunction with Amazon's recent update for RDS with PostgreSQL[2] which includes logical replication support. The concern I currently have is the stability and output format of the test_decoding plugin. Specifically if it's built to han

Re: [GENERAL] How to optimize SELECT query with multiple CASE statements?

2016-10-31 Thread Alexander Farber
Hi Geoff, On Mon, Oct 31, 2016 at 4:21 PM, Geoff Winkless wrote: > > You could break the game table apart into game and gameplayer. > > That's more "normal" and fits much more nicely, IMO, and you could > then resolve the CASE by using joins between game and (twice) > gameplayer: > > SELECT ...

Re: [GENERAL] initdb createuser commands

2016-10-31 Thread Alban Hertroys
On 31 October 2016 at 15:50, Christofer C. Bell wrote: > > I think the OP's point is that having a hodgepodge of (on their face) > unrelated commands smells kinda unorganized at best and unprofessional at > worst. Wether or not he's right is up to the reader. For me, I agree with > his sentimen

Re: [GENERAL] How to optimize SELECT query with multiple CASE statements?

2016-10-31 Thread Geoff Winkless
On 31 October 2016 at 15:21, Geoff Winkless wrote: > LEFT JOIN words_social s1 ON s1.uid = in_uid > LEFT JOIN words_social s2 ON CASE WHEN g.player1 = in_uid THEN > g.player2 ELSE g.player1 Ugh. Of course I meant LEFT JOIN words_social s1 ON s1.uid = in_uid LEFT JOIN words_social s2 ON s2.uid =

Re: [GENERAL] How to optimize SELECT query with multiple CASE statements?

2016-10-31 Thread Geoff Winkless
On 31 October 2016 at 12:53, Alexander Farber wrote: > > Good afternoon, > > is it please posible to optimize the following SQL query with numerous CASE > statements (on same condition!) without switching to PL/pgSQL? You could break the game table apart into game and gameplayer. That's more "

Re: [GENERAL] initdb createuser commands

2016-10-31 Thread Melvin Davidson
On Mon, Oct 31, 2016 at 10:50 AM, Christofer C. Bell < christofer.c.b...@gmail.com> wrote: > On Sun, Oct 30, 2016 at 11:10 PM, Melvin Davidson > wrote: > >> >> >> >> >> On Sun, Oct 30, 2016 at 8:08 PM, Samuel Williams < >> space.ship.travel...@gmail.com> wrote: >> >>> Sorry, just to clarify, b "w

Re: [GENERAL] initdb createuser commands

2016-10-31 Thread Christofer C. Bell
On Sun, Oct 30, 2016 at 11:10 PM, Melvin Davidson wrote: > > > > > On Sun, Oct 30, 2016 at 8:08 PM, Samuel Williams < > space.ship.travel...@gmail.com> wrote: > >> Sorry, just to clarify, b "worst" I don't mean functionality, I mean >> the way the commands are named and organised. >> >> On 31 Oct

Re: [GENERAL] Rows are repeating by the trigger function

2016-10-31 Thread Alban Hertroys
On 31 October 2016 at 14:41, Adrian Klaver wrote: > On 10/31/2016 02:06 AM, Kiran wrote: >> I know 94 = 1 + (3 * 31). >> I am just having a normal insert statement into cf_question table. > > Are there any other triggers on the tables? I'm fairly confident that the duplicates are from updates on

Re: [GENERAL] Way to quickly detect if database tables/columns/etc. were modified?

2016-10-31 Thread Steve Crawford
Not sure if it would work for your use-case but what about just monitoring the PostgreSQL log for DDL statements? You may have to filter out temp tables (as you might in the system catalogs as well) but you could probably also watch for specific tablename patterns in case you only need to invalidat

Re: [GENERAL] Way to quickly detect if database tables/columns/etc. were modified?

2016-10-31 Thread Adrian Klaver
On 10/31/2016 07:17 AM, Melvin Davidson wrote: > > > On Mon, Oct 31, 2016 at 9:48 AM, Karsten Hilbert > mailto:karsten.hilb...@gmx.net>> wrote: > > On Mon, Oct 31, 2016 at 09:14:07AM -0400, Melvin Davidson wrote: > > >> Maybe create an event trigger that updates a simple table with the

Re: [GENERAL] How to hint 2 coulms IS NOT DISTINCT FROM each other

2016-10-31 Thread Kim Rose Carlsen
On Sat, Oct 29, 2016 at 8:27 AM, Kim Rose Carlsen wrote: > > I have tried creating a function called > > zero_if_null(int) : int that just select COALESCE($1, 0) > > and adding a index on (zero_if_null(customer_id)) on table that contains > > customer_id. The only thing I get from is the planner

Re: [GENERAL] Way to quickly detect if database tables/columns/etc. were modified?

2016-10-31 Thread Melvin Davidson
On Mon, Oct 31, 2016 at 9:48 AM, Karsten Hilbert wrote: > On Mon, Oct 31, 2016 at 09:14:07AM -0400, Melvin Davidson wrote: > > >> Maybe create an event trigger that updates a simple table with the last > >> modification time or sends a notification? > ... > > That would certainly work, but > > th

Re: [GENERAL] How to optimize SELECT query with multiple CASE statements?

2016-10-31 Thread Adrian Klaver
On 10/31/2016 05:53 AM, Alexander Farber wrote: Good afternoon, is it please posible to optimize the following SQL query with numerous CASE statements (on same condition!) without switching to PL/pgSQL? Offered with the following caveats, one I do not fully understand what is going on below a

[GENERAL] How is Greenplum's partitioning different from PG's inheritance

2016-10-31 Thread Rakesh Kumar
Reading the following two: http://www.greenplumdba.com/partitioning-in-greenplum http://gpdb.docs.pivotal.io/4350/admin_guide/ddl/ddl-partition.html It is clear that GP's partitioning is just a skin on top of inheritance. Does anyone know how GP implements the insert re-routing. Is it done vi

Re: [GENERAL] Way to quickly detect if database tables/columns/etc. were modified?

2016-10-31 Thread Karsten Hilbert
On Mon, Oct 31, 2016 at 09:14:07AM -0400, Melvin Davidson wrote: >> Maybe create an event trigger that updates a simple table with the last >> modification time or sends a notification? ... > That would certainly work, but > the problem is, that trigger would have to be created for every table in

Re: [GENERAL] Rows are repeating by the trigger function

2016-10-31 Thread Adrian Klaver
On 10/31/2016 02:06 AM, Kiran wrote: Hi Adrian, I want the trigger function to insert a row in cf_user_question_link table with fields as show in the function once the there is a insert from in the cf_question table. If so and I think this was mentioned before, why the UPDATE in the trigger

[GENERAL] If pg_ctl dies, can we attach a new pg_ctl process to postgres?

2016-10-31 Thread Daevor The Devoted
Hi On a Windows 10 system (using pg9.3), we have occasionally noted that the pg_ctl process is not running, but the main postgres.exe process is. Windows services then reports postgres as not running, when it is actually is. Is it thus possible to start up a new pg_ctl process, and "attach" it to

Re: [GENERAL] How to hint 2 coulms IS NOT DISTINCT FROM each other

2016-10-31 Thread Merlin Moncure
On Sat, Oct 29, 2016 at 8:27 AM, Kim Rose Carlsen wrote: >>> This doesn't do much good. This doesn't tell the planner that the 3 > >>> customer_ids are actually of same value, and it therefore can't filter >>> them >>> as it sees fit. > >> You do know you can index on a function, and the planner t

Re: [GENERAL] Way to quickly detect if database tables/columns/etc. were modified?

2016-10-31 Thread Melvin Davidson
On Mon, Oct 31, 2016 at 8:54 AM, John DeSoi wrote: > > > On Oct 30, 2016, at 4:45 AM, Evan Martin > wrote: > > > > If I have a query that reads from system tables like pg_class, > pg_namespace, pg_attribute, pg_type, etc. and I'd like to cache the results > in my application is there any fast wa

Re: [GENERAL] Way to quickly detect if database tables/columns/etc. were modified?

2016-10-31 Thread John DeSoi
> On Oct 30, 2016, at 4:45 AM, Evan Martin > wrote: > > If I have a query that reads from system tables like pg_class, pg_namespace, > pg_attribute, pg_type, etc. and I'd like to cache the results in my > application is there any fast way to detect when any changes have been made > to these

[GENERAL] How to optimize SELECT query with multiple CASE statements?

2016-10-31 Thread Alexander Farber
Good afternoon, is it please posible to optimize the following SQL query with numerous CASE statements (on same condition!) without switching to PL/pgSQL? SELECT g.gid, EXTRACT(EPOCH FROM g.created)::int, EXTRACT(EPOCH FROM g.finished)::int, g.letters,

Re: [GENERAL] Rows are repeating by the trigger function

2016-10-31 Thread Kiran
Hi Adrian, I want the trigger function to insert a row in cf_user_question_link table with fields as show in the function once the there is a insert from in the cf_question table. I know 94 = 1 + (3 * 31). I am just having a normal insert statement into cf_question table. regards Kiran On Sun