If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Performance question: check by date or check by bool?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-25-07, 06:20
jmpfffc jmpfffc is offline
Registered User
 
Join Date: Jan 2007
Posts: 12
Performance question: check by date or check by bool?

This is just a simple question about performance: say you have a big list of events, some past and some in the future. The past events will not be used other than for statistics. What's the best way to query the database about future events:

... WHERE date > NOW()

...or...

... WHERE hasbeenprocessed = FALSE
Reply With Quote
  #2 (permalink)  
Old 05-25-07, 08:40
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
i would go with the date comparison, simply because as far as i know mysql doesn't support booleans
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 05-29-07, 02:57
jmpfffc jmpfffc is offline
Registered User
 
Join Date: Jan 2007
Posts: 12
I really meant to ask if calculating this by date was slower than an other way (I gave the example of a bool, but it could be a tinyint or enum). Is would seem that checking for a "flag" is quicker than comparing dates.
Reply With Quote
  #4 (permalink)  
Old 05-29-07, 03:58
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
it would seem? you'll need to run a volume test then
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On