Index
2012-05-04 04:36 – Vineet Deodhar : [dabo-users] postgres pkid before commit
2012-05-04 06:57 – John Fabiani : Re: [dabo-users] postgres pkid before commit
2012-05-04 07:20 – Ricardo Araoz : Re: [dabo-users] postgres pkid before commit
Back to top
[dabo-users] postgres pkid before commit

Author: Vineet Deodhar

Posted: 2012-05-04 04:36:30   Link

> On 5/3/12 9:06 PM, Vineet Deodhar wrote:

> > Isn't it dangerous to get a pkid from the db before commit?

> > Consider a situation where UserA gets a pkid "2564' for a table "tbl1".

> > Before this change is committed, UserB inserts a record to tbl1& gets

> > "2564".

> >

> > Wouldn't is cause a mess?

>

>

> No, postgres knows it handed out 2564 already, even though it isn't

> committed yet.

>

> Paul

>

>

I see.

In that case, it would lead to further trouble such as -->

UserA, after getting pkid 2564 for tbl1, cancels the addition.

So 5264 is unutilized.

If the no. of users & data-traffic is quite low, no issue.

But consider a case where hundreds of users are interacting with tbl1 and

there are a lot of cases for cancelled additions to tbl1.

In effect, even if the smallint data-type for this pkid is sufficient, the

DBA has to opt for maybe mediumint !

Anyway, I am using MySQL and I am very much comfortable with it.

-- Vineet

> > Postgres can provide the PK from a record before it is committed.

> >

> > transaction

> > begin

> > insert record

> > retrieve PK (I will assume that is a serial data type).

> > insert record

> > retrieve PK

> > continue

> >

> > commit or rollback

> >

> > I realize that Dabo does not do it but I do it all the time with Dabo

> temp

> > cursors.

> >

> > Johnf

>

--- StripMime Report -- processed MIME parts ---

multipart/alternative

text/plain (text body -- kept)

text/html

---

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/CAP5=7op_tpJLE-8hFsD9Ubdk24gZb+gFNTwTxg=J_zb7FLYYqg@mail.gmail.com

©2012 Vineet Deodhar
Back to top
Re: [dabo-users] postgres pkid before commit

Author: John Fabiani

Posted: 2012-05-04 06:57:04   Link

On Friday, May 04, 2012 03:06:30 PM Vineet Deodhar wrote:

> Anyway, I am using MySQL and I am very much comfortable with it.

>

> -- Vineet\

Tell me how MySQL does it differently?

Johnf

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/2485655.Xo1rrKhCtb@linux-12

©2012 John Fabiani
Back to top
Re: [dabo-users] postgres pkid before commit

Author: Ricardo Araoz

Posted: 2012-05-04 07:20:32   Link

El 04/05/12 06:36, Vineet Deodhar escribió:

>> On 5/3/12 9:06 PM, Vineet Deodhar wrote:

>>> Isn't it dangerous to get a pkid from the db before commit?

>>> Consider a situation where UserA gets a pkid "2564' for a table "tbl1".

>>> Before this change is committed, UserB inserts a record to tbl1& gets

>>> "2564".

>>>

>>> Wouldn't is cause a mess?

>

>

>> No, postgres knows it handed out 2564 already, even though it isn't

>> committed yet.

>>

>> Paul

>>

>>

> I see.

>

> In that case, it would lead to further trouble such as -->

> UserA, after getting pkid 2564 for tbl1, cancels the addition.

> So 5264 is unutilized.

>

> If the no. of users & data-traffic is quite low, no issue.

> But consider a case where hundreds of users are interacting with tbl1 and

> there are a lot of cases for cancelled additions to tbl1.

>

> In effect, even if the smallint data-type for this pkid is sufficient, the

> DBA has to opt for maybe mediumint !

>

> Anyway, I am using MySQL and I am very much comfortable with it.

>

> -- Vineet

>

I'd never use smallint or mediumint for a pkid!

If the table is small enough then you are not saving much space. If it

is big then it will not scale properly. I guess RDBMs define pkid type

according to maximum database size in records, and then some in order to

have ample space to cover for what you specify.

_______________________________________________

Post Messages to: Dabo-users@leafe.com

Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users

Searchable Archives: http://leafe.com/archives/search/dabo-users

This message: http://leafe.com/archives/byMID/4FA3C990.20606@gmail.com

©2012 Ricardo Araoz