dbTalk Databases Forums  

timestamp precision

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss timestamp precision in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
A Gilmore
 
Posts: n/a

Default timestamp precision - 09-13-2004 , 03:19 AM






Hello,

Im using the default precision for my timestamps, 6. Is it safe to
declare this column unique? Because you can define the level of
precision I assume you could theoretically have a duplicate. Or does a
precision of 6 give you an accuracy at the point where pgsql could never
do 2 transactions in the given timestamp time span?

I likely could have written this better, I hope its understandable.

Thank you in advance.

A Gilmore

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #2  
Old   
Michael Glaesemann
 
Posts: n/a

Default Re: timestamp precision - 09-13-2004 , 03:30 AM







On Sep 13, 2004, at 4:19 PM, A Gilmore wrote:

Quote:
Hello,

Im using the default precision for my timestamps, 6. Is it safe to
declare this column unique?
The *only* way to ensure uniqueness in a column is to explicitly
declare the column UNIQUE or PRIMARY (which implies UNIQUE NOT NULL
iirc). So if you declare it unique, of course it's safe.

If you are assuming it's unique because of the high precision, well,
you might get lucky, and you might not. (Some might even argue that
it's for all intents and purposes unique). However, if you want to
guarantee uniqueness, declare it UNIQUE.

Michael Glaesemann
grzm myrealbox com


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



Reply With Quote
  #3  
Old   
Kumar S
 
Posts: n/a

Default Re: create table error - 09-13-2004 , 09:35 AM



Dear group,
I am getting a constant error that says Parse error
at "(".

I am using 7.4 and I never had this kind of problem in
previous versions.

lines of my code:

create table contacts
(
con_id serial ,
exp_id serial REFERENCES experiment,
con_lname varchar(32) ,
con_fname varchar(32) ,
con_addressline varchar (64),
con_zip varchar(16) ,
);
Is there some problem with these sql statements.
please help.

Thank you.

psk






__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
  #4  
Old   
Michael Glaesemann
 
Posts: n/a

Default Re: create table error - 09-13-2004 , 09:43 AM




On Sep 13, 2004, at 10:35 PM, Kumar S wrote:
Quote:
create table contacts
(
con_id serial ,
exp_id serial REFERENCES experiment,
con_lname varchar(32) ,
con_fname varchar(32) ,
con_addressline varchar (64),
con_zip varchar(16) ,
);
Is there some problem with these sql statements.
Yes. You have an extra comma following the line beginning con_zip. The
last line of the table definition should not be followed by a comma.

I suspect you're also going to have trouble with the exp_id serial
references experiment line. You probably don't want a default on a
column that needs to match a value in another table.

Hope that helps.

Also, please do not start a new thread by replying to a different
message. Create a new message instead.

Michael Glaesemann
grzm myrealbox com


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)



Reply With Quote
  #5  
Old   
Devrim GUNDUZ
 
Posts: n/a

Default Re: create table error - 09-13-2004 , 09:43 AM



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hi,

On Mon, 13 Sep 2004, Kumar S wrote:

Quote:
I am getting a constant error that says Parse error
at "(".

I am using 7.4 and I never had this kind of problem in
previous versions.
The lines below would never ever work in any PostgreSQL server...

Quote:
lines of my code:

create table contacts
(
con_id serial ,
exp_id serial REFERENCES experiment,
con_lname varchar(32) ,
con_fname varchar(32) ,
con_addressline varchar (64),
con_zip varchar(16) ,
);
con_zip varchar(16) ,

would be

con_zip varchar(16)

You cannot use a comma after the last column definition.

Regards,
- --
Devrim GUNDUZ
devrim~gunduz.org devrim.gunduz~linux.org.tr
http://www.tdmsoft.com
http://www.gunduz.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFBRaQLtl86P3SPfQ4RAnPnAJ41BEsJvrz+CJGKckByVH ag0pJ9xQCgjZIK
w0A+rtK/XRljlbjOV+Dxfsc=
=SJ6k
-----END PGP SIGNATURE-----

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html



Reply With Quote
  #6  
Old   
Tom Lane
 
Posts: n/a

Default Re: timestamp precision - 09-13-2004 , 10:28 AM



Michael Glaesemann <grzm (AT) myrealbox (DOT) com> writes:
Quote:
On Sep 13, 2004, at 4:19 PM, A Gilmore wrote:
Im using the default precision for my timestamps, 6. Is it safe to
declare this column unique?

If you are assuming it's unique because of the high precision, well,
you might get lucky, and you might not. (Some might even argue that
it's for all intents and purposes unique).
I think what he's wondering is whether every two transactions will get
distinguishable values of now(), so that putting a UNIQUE constraint on
timestamps inserted by distinct transactions could never fail.

I think this is an unsafe assumption, because:

1. The amount of precision that is actually in the now() value is
unspecified, and varies depending on the hardware and OS. On older
machines it's quite possible that now() only advances once per clock
tick interrupt (60 or 100 times per second).

2. Even if the now() quantum is less than the minimum time to complete
a transaction, what if two clients launch transactions concurrently?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



Reply With Quote
  #7  
Old   
A Gilmore
 
Posts: n/a

Default Re: timestamp precision - 09-13-2004 , 12:30 PM



Tom Lane wrote:
Quote:
Michael Glaesemann <grzm (AT) myrealbox (DOT) com> writes:

On Sep 13, 2004, at 4:19 PM, A Gilmore wrote:

Im using the default precision for my timestamps, 6. Is it safe to
declare this column unique?


If you are assuming it's unique because of the high precision, well,
you might get lucky, and you might not. (Some might even argue that
it's for all intents and purposes unique).


I think what he's wondering is whether every two transactions will get
distinguishable values of now(), so that putting a UNIQUE constraint on
timestamps inserted by distinct transactions could never fail.

I think this is an unsafe assumption, because:

Yeah, thats what I was meaning. I didn't think it would work (by work,
I mean no chance of failure due to duplicate) but was hoping to be suprised.

Thank you for the insight.

A Gilmore

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.