Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread David G. Johnston
On Mon, Aug 24, 2015 at 9:15 AM, Ray Cote rgac...@appropriatesolutions.com wrote: On Sat, Aug 22, 2015 at 11:46 AM, Karsten Hilbert karsten.hilb...@gmx.net wrote: 1. Prefix ALL literals with an Escape EG: SELECT E'This is a \'quoted literal \''; SELECT E'This is an unquoted

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Melvin Davidson
David, Thank you. This is exactly the type of feedback I was looking for. To answer your question, for now it is a guide for one particular client, however, if I get enough feedback and contributions, I will revise it and submit to the PostgreSQL community. On Mon, Aug 24, 2015 at 2:34 AM,

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Melvin Davidson
9. 1) What happens if someone mis-types the account-id? To correct that, you also need to correct the FK field in the other dozen tables. 2) What happens when your company starts a new project (or buys a competitor) and all the new account numbers are alpha-numeric? I would reply that in

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Ray Cote
On Sat, Aug 22, 2015 at 11:46 AM, Karsten Hilbert karsten.hilb...@gmx.net wrote: 1. Prefix ALL literals with an Escape EG: SELECT E'This is a \'quoted literal \''; SELECT E'This is an unquoted literal'; Doing so will prevent the annoying WARNING: nonstandard use of

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread David G. Johnston
On Mon, Aug 24, 2015 at 9:27 AM, Melvin Davidson melvin6...@gmail.com wrote: 9. 1) What happens if someone mis-types the account-id? To correct that, you also need to correct the FK field in the other dozen tables. 2) What happens when your company starts a new project (or buys a

[GENERAL] Invalid memory alloc request size

2015-08-24 Thread Mike James
Over the weekend, Amazon did some maintenance that resulted in one of our instances being restarted. Apparently this left the database in a bad state. This particular instance functions as a slony replication target and when I went to start up slony, I get the following error message. Here's some

Re: [GENERAL] Problem with database connections timing out for long-running queries

2015-08-24 Thread Rich Schaaf
I am using the default TIMEOUTidle setting in stunnel so that seems plausible. Thanks very much for pointing me in what sounds like the right direction! Kind regards, Rich From: Steve Crawford [mailto:scrawf...@pinpointresearch.com] Sent: Friday, August 21, 2015 6:25 PM To: Rich

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Melvin Davidson
What then if it is discovered that the keyed in value was mis-typed? That is why SQL has UPDATE and DELETE statements. If a primary key is incorrect, it can be fixed, be it one method of another. On Mon, Aug 24, 2015 at 10:04 AM, David G. Johnston david.g.johns...@gmail.com wrote: On Mon, Aug

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread John Turner
On Mon, 24 Aug 2015 09:15:27 -0400, Ray Cote rgac...@appropriatesolutions.com wrote: 9. Do NOT arbitrarily assign an id column to a table as a primary key when other columns are perfectly suited as a unique primary key. ... Good example: CREATE TABLE accounts (

[GENERAL] AIX 7.1 compile and initdb startup error TRAP: FailedAssertion

2015-08-24 Thread Pande, Nitin
Hi, I am trying to compile and run PostgreSQL 9.4.0 on AIX 7.1. I was able to compile with following settings: CC=xlc_r -q64 -qnoansialias CFLAGS=-g -O0 AR=ar -X64 OBJECT_MODE=64 ./configure --enable-cassert --enable-debug -with-includes=/opt/freeware/include --with-libraries=/opt/freeware/lib

[GENERAL] AIX 7.1 compile and initdb startup error TRAP: FailedAssertion

2015-08-24 Thread Pande, Nitin
Hello, I am trying to compile and run PostgreSQL 9.4.0 on AIX 7.1. I was able to compile with following settings: CC=xlc_r -q64 -qnoansialias CFLAGS=-g -O0 AR=ar -X64 OBJECT_MODE=64 ./configure --enable-cassert --enable-debug -with-includes=/opt/freeware/include

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread David G. Johnston
On Mon, Aug 24, 2015 at 10:32 AM, Melvin Davidson melvin6...@gmail.com wrote: What then if it is discovered that the keyed in value was mis-typed? That is why SQL has UPDATE and DELETE statements. If a primary key is incorrect, it can be fixed, be it one method of another. ​Yes, a DBA can

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Joshua D. Drake
On 08/24/2015 07:58 AM, John Turner wrote: On Mon, 24 Aug 2015 09:15:27 -0400, Ray Cote Point 9 is well-intentioned, but perhaps needs to be clarified/rephrased: Developers should not be creating production-grade tables devoid of well-defined business keys, period. That would be regardless

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Joshua D. Drake
On 08/24/2015 08:56 AM, Melvin Davidson wrote: The serial key is the default primary key amongst every single web development environment in existence. Methinks thou doest take too much for granted. Yes, serial has it's purpose, but I sincerely doubt it is the default primary key amongst

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Melvin Davidson
And again, I am talking about _database_ design, not Web apps. Letting Web developers design a database to work with their app, is a very, Very, VERY bad idea. It is far better to let DBA's and database develeopers design a good database, then to let those apps mold a db into a non-optimum design.

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Adrian Klaver
On 08/24/2015 09:34 AM, Melvin Davidson wrote: And again, I am talking about _database_ design, not Web apps. Letting Web developers design a database to work with their app, is a very, Very, VERY bad idea. Again this is not restricted to Web apps. Anything that touches a database via an ORM

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Melvin Davidson
The serial key is the default primary key amongst every single web development environment in existence. Methinks thou doest take too much for granted. Yes, serial has it's purpose, but I sincerely doubt it is the default primary key amongst every single web development environment in existence

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Adrian Klaver
On 08/24/2015 08:56 AM, Melvin Davidson wrote: The serial key is the default primary key amongst every single web development environment in existence. Methinks thou doest take too much for granted. Yes, serial has it's purpose, but I sincerely doubt it is the default primary key amongst

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Joshua D. Drake
On 08/24/2015 09:34 AM, Melvin Davidson wrote: And again, I am talking about _database_ design, not Web apps. Letting Web developers design a database to work with their app, is a very, Very, VERY bad idea. And I don't argue that but we also live in a world based on reality. DBAs are rare,

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread John Turner
On Mon, 24 Aug 2015 12:40:37 -0400, Joshua D. Drake j...@commandprompt.com wrote: On 08/24/2015 09:34 AM, Melvin Davidson wrote: And again, I am talking about _database_ design, not Web apps. Letting Web developers design a database to work with their app, is a very, Very, VERY bad idea.

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread John R Pierce
On 8/24/2015 9:34 AM, Melvin Davidson wrote: And again, I am talking about _database_ design, not Web apps. Letting Web developers design a database to work with their app, is a very, Very, VERY bad idea. It is far better to let DBA's and database develeopers design a good database, then to

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Melvin Davidson
Thank you John R. Pierce. Finally someone who understands the purpose of this thread. Otherwise, next thing you know, we'll have Web apps/developers designing bra's for milk cows so they'll look better in the field. :) On Mon, Aug 24, 2015 at 1:05 PM, John R Pierce pie...@hogranch.com wrote: On

Re: [GENERAL] master/master replication with load balancer in front

2015-08-24 Thread Florin Andrei
On 2015-08-23 06:56, Martín Marqués wrote: El 21/08/15 a las 20:45, Florin Andrei escribió: The single instance scheme is not very reliable. I need to build a new DB backend. I'll set up Postgres 9.4. Ideally, I'd like to setup 2 instances, each instance placed in a different availability

Re: [GENERAL] master/master replication with load balancer in front

2015-08-24 Thread Florin Andrei
On 2015-08-22 03:05, Chris Mair wrote: a few keywords in your mail hint at the fact you're using AWS? If that's the case, you might want to look into their managed PostgreSQL hosting: it's called Amazon RDS for PostgreSQL and supports failover (Multi AZ) and master-slave replication (Read

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Thomas Kellerer
Melvin Davidson schrieb am 22.08.2015 um 21:40: Thank you for pointing out run with standard_conforming_strings = ON.. However, that is NOT the problem. What is occurring is that the developers are sending strings like 'Mr. M\'vey', which, if we set standard_conforming_strings = ON, would,

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Thomas Kellerer
Melvin Davidson schrieb am 22.08.2015 um 17:15: I've attached a file with a few starters that although are numbered, are in no special order. 2. End ALL queries with a semi-colon (;) EG: SELECT some_column FROM a_table; Although autocommit is on by default, it is always a good

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread CaT
On Mon, Aug 24, 2015 at 08:22:17PM -0400, Melvin Davidson wrote: On Mon, Aug 24, 2015 at 8:00 PM, Berend Tober bto...@computer.org wrote: 1) What happens if someone mis-types the account-id? To correct that, you also need to correct the FK field in the other dozen tables.

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Gavin Flower
On 25/08/15 02:58, John Turner wrote: [...] Conversely, if synthetic keys are chosen as Primary, they must be accompanied by a legitimate Unique natural key. Agreed, but only where appropriate. Cheers, Gavin -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Melvin Davidson
ON UPDATE CASCADE ? I believe he's talking about triggers. On Mon, Aug 24, 2015 at 8:00 PM, Berend Tober bto...@computer.org wrote: Melvin Davidson wrote: 9. 1) What happens if someone mis-types the account-id? To correct that, you also need to correct the FK field in the other

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Melvin Davidson
You are right, he was probably talking about FK's. I was just so frustrated about people insisting that using ID as the primary key in every table is a good idea, I didn't bother to reply previously. I stand firm on my belief that the primary key should be something meaningful and NOT id just for

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Gavin Flower
On 25/08/15 01:15, Ray Cote wrote: On Sat, Aug 22, 2015 at 11:46 AM, Karsten Hilbert karsten.hilb...@gmx.net mailto:karsten.hilb...@gmx.net wrote: [...] 9. Do NOT arbitrarily assign an id column to a table as a primary key when other columns are perfectly suited as a unique

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread CaT
On Mon, Aug 24, 2015 at 08:53:43PM -0400, Melvin Davidson wrote: You are right, he was probably talking about FK's. I was just so frustrated about people insisting that using ID as the primary key in every table is a good idea, I didn't bother to reply previously. I stand firm on my belief

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Gavin Flower
On 25/08/15 04:26, Joshua D. Drake wrote: On 08/24/2015 08:56 AM, Melvin Davidson wrote: The serial key is the default primary key amongst every single web development environment in existence. Methinks thou doest take too much for granted. Yes, serial has it's purpose, but I sincerely doubt

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread David G. Johnston
On Mon, Aug 24, 2015 at 10:02 PM, Gavin Flower gavinflo...@archidevsys.co.nz wrote: Also the best practice is to make the primary key name 'id' as you do know the table it is in, so prepending the table name is redundant - so you can clearly identify foreign keys because the suffix '_id 'is

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Gavin Flower
On 25/08/15 14:45, David G. Johnston wrote: On Mon, Aug 24, 2015 at 10:02 PM, Gavin Flower gavinflo...@archidevsys.co.nz mailto:gavinflo...@archidevsys.co.nzwrote: Also the best practice is to make the primary key name 'id' as you do know the table it is in, so prepending the table

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-24 Thread Rob Sargent
On Aug 24, 2015, at 6:53 PM, Melvin Davidson melvin6...@gmail.com wrote: You are right, he was probably talking about FK's. I was just so frustrated about people insisting that using ID as the primary key in every table is a good idea, I didn't bother to reply previously. I stand firm on