 |

05-14-2004, 01:17 AM
|
 |
Greater Overmind
Greater Overmind
|
|
Join Date: Feb 2003
Location: Colorado
Posts: 887
Rep Power: 6
|
|
PHP/MySQL delay of processing
Apparently two of my MySQL INSERT statements run too fast to ensure that the datetimes are at least one second off of each other. Anyone have any suggestions as to the best way to ensure two 'modified' dates are at least 1 second apart so that I may properly order them using ORDER BY.
__________________
I do not feel obliged to believe that the same God who has endowed us with sense, reason, and intellect has intended us to forgo their use. - Galileo Galilei
Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. - Thomas Jefferson (3rd US President, author of the Declaration of Independence)
Justice is the [ultimate goal] of government. It is the [ultimate goal] of civil society. It ever has been and ever will be pursued until it be obtained, or until liberty be lost in the pursuit. - James Madison (4th US President, "father" of the US Constitution)
|

05-14-2004, 02:20 AM
|
 |
Administrator
Great Diviner
|
|
Join Date: Aug 2002
Location: Maine
Posts: 5,248
Rep Power: 10
|
|
Well, if you really want to force them to be one second apart, you can grab the current unix timestamp and increment by one on each insert; then convert to the proper format using PHP's date() function, then run the query.
If you have concurrent INSERT's this will foul everything up of course. Additionally, if you're inserting a lot of records the timestamp will get increasingly less accurate. 2,000 records will introduce almost a 30 minute gap in your data, while the INSERTs should be well under a minute on a reasonable server. The faster the hardware gets, the larger the recordsets, the wider the gap. 100,000 INSERT's on a dedicated quad-Xeon with 4GB of RAM would introduce a nearly 28 hour gap, under ideal conditions ~1:1680 ratio to the actual timestamps.
Okay, that's probably far from what you're trying to accomplish, but it's fun to speculate.
If you can't just depend on an autonumber field, which will always be sequential even on concurrent INSERT's, you could create an index (not a MySQL table index, just a ticker so to speak), and save each incremented index to a new column in your table. As long as you're only concerned with sorting on each batch, that would be sufficient (if not introducing some possibly unnecessary overhead).
Maybe I'm missing your point though -- you said two queries, so the situation could be different if you're comparing just these pairs.
|

05-14-2004, 10:07 AM
|
 |
Greater Overmind
Greater Overmind
|
|
Join Date: Feb 2003
Location: Colorado
Posts: 887
Rep Power: 6
|
|
 Interesting... I never thought about all that. Anywho, I'm just talking about two INSERTs that run back to back, not more. What it is that I'm trying to do is create a discussion link between my forum and my blog such that first a new thread is created, then the first post (the first INSERT I need to worry about) will quote the blog entry and the second post (second INSERT) will be the user's actual discussion text.
However, now that I'm looking at this from another angle - now this morning - I could simply combine the quote and the discussion into one post and not worry about it.
__________________
I do not feel obliged to believe that the same God who has endowed us with sense, reason, and intellect has intended us to forgo their use. - Galileo Galilei
Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. - Thomas Jefferson (3rd US President, author of the Declaration of Independence)
Justice is the [ultimate goal] of government. It is the [ultimate goal] of civil society. It ever has been and ever will be pursued until it be obtained, or until liberty be lost in the pursuit. - James Madison (4th US President, "father" of the US Constitution)
|

05-14-2004, 10:09 AM
|
 |
Greater Overmind
Greater Overmind
|
|
Join Date: Feb 2003
Location: Colorado
Posts: 887
Rep Power: 6
|
|
I love rhetorical logic...
__________________
I do not feel obliged to believe that the same God who has endowed us with sense, reason, and intellect has intended us to forgo their use. - Galileo Galilei
Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. - Thomas Jefferson (3rd US President, author of the Declaration of Independence)
Justice is the [ultimate goal] of government. It is the [ultimate goal] of civil society. It ever has been and ever will be pursued until it be obtained, or until liberty be lost in the pursuit. - James Madison (4th US President, "father" of the US Constitution)
|

05-14-2004, 07:22 PM
|
 |
Greater Overmind
Greater Overmind
|
|
Join Date: Feb 2003
Location: Colorado
Posts: 887
Rep Power: 6
|
|
Using 'ORDER BY created DESC, id ASC' works just great of course! Thx.
__________________
I do not feel obliged to believe that the same God who has endowed us with sense, reason, and intellect has intended us to forgo their use. - Galileo Galilei
Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. - Thomas Jefferson (3rd US President, author of the Declaration of Independence)
Justice is the [ultimate goal] of government. It is the [ultimate goal] of civil society. It ever has been and ever will be pursued until it be obtained, or until liberty be lost in the pursuit. - James Madison (4th US President, "father" of the US Constitution)
|

05-16-2004, 05:21 PM
|
 |
Administrator
Great Diviner
|
|
Join Date: Aug 2002
Location: Maine
Posts: 5,248
Rep Power: 10
|
|
Right on!
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:29 PM.
|
|