Re: [GENERAL] Column order in multi column primary key

2016-08-09 Thread Kevin Grittner
On Mon, Aug 8, 2016 at 5:59 PM, Craig Boucher wrote: > Thanks Kevin for your response. I've Googled and debated natural > vs surrogate keys and I just find surrogate keys easier to work > with (maybe I'm just being lazy). It just seems that a > description or name is most

Re: [GENERAL] Column order in multi column primary key

2016-08-08 Thread Craig Boucher
PM To: Craig Boucher <cr...@wesvic.com> Cc: Tom Lane <t...@sss.pgh.pa.us>; David G. Johnston <david.g.johns...@gmail.com>; pgsql-general@postgresql.org Subject: Re: [GENERAL] Column order in multi column primary key On Mon, Aug 8, 2016 at 4:01 PM, Craig Boucher <cr...@wesv

Re: [GENERAL] Column order in multi column primary key

2016-08-08 Thread Kevin Grittner
On Mon, Aug 8, 2016 at 4:01 PM, Craig Boucher wrote: > From: Tom Lane [mailto:t...@sss.pgh.pa.us] >> I'm pretty skeptical of the notion of redefining what your PK >> is on performance grounds. With this definition, you'd allow >> two entries with the same work_session_id, if

Re: [GENERAL] Column order in multi column primary key

2016-08-08 Thread Craig Boucher
To: Craig Boucher <cr...@wesvic.com> Cc: 'David G. Johnston' <david.g.johns...@gmail.com>; pgsql-general@postgresql.org Subject: Re: [GENERAL] Column order in multi column primary key "Craig Boucher" <cr...@wesvic.com> writes: > I should have pointed out in my las

Re: [GENERAL] Column order in multi column primary key

2016-08-08 Thread Tom Lane
"Craig Boucher" writes: > I should have pointed out in my last response that I was wondering if the > performance of the pk index on work_session would be better if my primary key > was (customer_id, work_session_id) or if (work_session_id, customer_id) will > be fine.

Re: [GENERAL] Column order in multi column primary key

2016-08-08 Thread David G. Johnston
On Mon, Aug 8, 2016 at 4:35 PM, Craig Boucher wrote: > Thanks David. I’ve thought about the hierarchy you mentioned but the > hierarchy can change and I need to capture it as it was when the data was > generated. > > > > I should have pointed out in my last response that I was

Re: [GENERAL] Column order in multi column primary key

2016-08-08 Thread Craig Boucher
...@gmail.com] Sent: Monday, August 8, 2016 12:43 PM To: Craig Boucher <cr...@wesvic.com> Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Column order in multi column primary key On Mon, Aug 8, 2016 at 3:06 PM, Craig Boucher <cr...@wesvic.com <mailto:cr...@wesvic.com> > w

Re: [GENERAL] Column order in multi column primary key

2016-08-08 Thread David G. Johnston
On Mon, Aug 8, 2016 at 3:06 PM, Craig Boucher wrote: > Here is one of the tables that can have millions of rows and foreign key > constraints to 5 other tables. > > > > CREATE TABLE public.work_session > > ( > > work_session_id integer NOT NULL DEFAULT nextval('worksession_ >

Re: [GENERAL] Column order in multi column primary key

2016-08-08 Thread Craig Boucher
om> Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Column order in multi column primary key On Mon, Aug 8, 2016 at 1:47 PM, Craig Boucher <cr...@wesvic.com <mailto:cr...@wesvic.com> > wrote: PG 9.5 I’m in the process of converting our application from Sql Server to Pos

Re: [GENERAL] Column order in multi column primary key

2016-08-08 Thread David G. Johnston
On Mon, Aug 8, 2016 at 1:47 PM, Craig Boucher wrote: > PG 9.5 > > > > I’m in the process of converting our application from Sql Server to > Postgresql. I’m taking advantage of this process to make some database > design changes. > > > > Our database contains data for many

[GENERAL] Column order in multi column primary key

2016-08-08 Thread Craig Boucher
PG 9.5 I'm in the process of converting our application from Sql Server to Postgresql. I'm taking advantage of this process to make some database design changes. Our database contains data for many customers and I have a customer_id column in every customer related table. One of the