Gossamer Forum
Quote Reply
dates
I'm doing some work on future dates and I need to use this statement -
select ddate from testdate where ddate = DATE_ADD(NOW(),INTERVAL 8 DAY) or ddate = DATE_ADD(NOW(),INTERVAL 4 DAY)

ddate is a date field added when the rec was created and is x number of days into the future.
Explain select for the above select gives the type as range, which is only just good.

A single select -
select ddate2 from testdate where ddate2 = DATE_ADD(NOW(),INTERVAL 30 DAY)
gives an explain select type as ref, which is better.

My question -
Would it be quicker on a large data set to use the double 'or' select, or would it be quicker to use two separate selects ie,
select ddate2 from testdate where ddate2 = DATE_ADD(NOW(),INTERVAL 8 DAY)
select ddate2 from testdate where ddate2 = DATE_ADD(NOW(),INTERVAL 4 DAY)

thanks

Bob
Quote Reply
Re: [lanerj] dates In reply to
Don't bother trying to answer my above question.
After thinking about it I don't think I can improve the first select.

It's for an email notification system which will be run by a cron job every night at times of least usage. It will be slow as it will need to send a large amount of email. I'll use SET SQL_BUFFER_RESULT to free up table locks. Is there anything else I can do to to speed things up?

thanks

Bob