Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old August 7th, 2003, 07:00 PM
sliver's Avatar
sliver sliver is online now
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 888 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 17 m 29 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
Speed?

Which is a faster/better way to store dates:
1)Using a datetime field type
or
2)Storing the unix timestamp in a int field

Reply With Quote
  #2  
Old August 7th, 2003, 07:04 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Speed?

as far as speed goes, the time it takes to insert a piece of data in the database is so small that I doubt you could tell the difference. As far as the data types goes, if you need to use any of the MySQL built in Date manipulation functions nuse datetime, if you don't plan on using the date functions then you could store the date any way you like.

Reply With Quote
  #3  
Old August 7th, 2003, 07:11 PM
sliver's Avatar
sliver sliver is online now
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 888 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 17 m 29 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
RE: Speed?

But which would you say is better?

Reply With Quote
  #4  
Old August 7th, 2003, 07:39 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Speed?

I would personally use datetime. As to whether it is better I never really gave it much thought and don't think I will...

NOTE: The above statement is worded as to avoid starting an argument on the subject that I don't have time for...

Reply With Quote
  #5  
Old August 7th, 2003, 07:44 PM
jaltiere jaltiere is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 55 jaltiere User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to jaltiere
RE: Speed?

I've used both methods, I prefer the datetime field also. I don't think there really is a huge advantage one way or the other though.


Reply With Quote
  #6  
Old August 7th, 2003, 08:54 PM
sliver's Avatar
sliver sliver is online now
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 888 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 17 m 29 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
RE: Speed?

OK thanks for your comments guys.

Reply With Quote
  #7  
Old August 8th, 2003, 11:23 AM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: Speed?

i prefer (and recommend) use of an int field instead...

Reply With Quote
  #8  
Old August 8th, 2003, 11:37 AM
jaltiere jaltiere is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 55 jaltiere User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to jaltiere
RE: Speed?

zombie,

out of curiosity why do you recommend using an int?
I used to use an int every time, but when I switched to using datetime I didn't notice any performance difference.

The reason I switched is because I was writing an application once and I had access to view the data as it was stored in the database. I was trying to debug some SQL statements and I couldn't determine if the date fields were correct without writing code to put it in a readable form, just glancing at the data didn't help me.

Reply With Quote
  #9  
Old August 8th, 2003, 01:20 PM
Sxooter Sxooter is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Chicago, IL, USA
Posts: 20 Sxooter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Sxooter
RE: Speed?

I use Postgresql, and in that database you have interval types, which means you can do all the date math in the database.

when MySQL gets around to adding interval types then the clear winner will be to use a "timestamp" type.

Note that MySQL decided timestamp types would be auto-updating for the current insert / update time, clearly against SQL spec, which lists it as the standard type for storing date/time, then MySQL created another type to handle date / time without the autoupdate.

They may have to reverse those two eventually, especially if they plan on integrating with SAPdb.

Reply With Quote
  #10  
Old August 8th, 2003, 04:05 PM
zombie zombie is offline
Codewalkers Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2007
Location: serbia
Posts: 1,876 zombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 3
RE: Speed?

jaltiere: it has nothing to do with speed.

it is just plain simpler than with sql commands. i like to keep as much of my logic (as i can) in php.

also, because you often need to present the date/time info to the user in not-mysql format, like "March 9th 2000" or whatever. that is much more easy to do with unix (int) time than with mysql time (you have to convert this one to unix time first.. see the extra step?)


btw, for that debugging purposes, you can always convert it to "human readable format" like so:

Code:
select from_unixtime(time) from table...


Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Speed?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway