SQL: Optimize insensive SELECTs on DateTime fields
        Posted  
        
            by Fedyashev Nikita
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Fedyashev Nikita
        
        
        
        Published on 2010-04-24T08:53:14Z
        Indexed on 
            2010/04/24
            8:53 UTC
        
        
        Read the original article
        Hit count: 185
        
I have an application for scheduling certain events. And all these events must be reviewed after each scheduled time.
So basically we have 3 tables:
- items(id, name)
- scheduled_items(id,item_id,execute_at- datetime) - item_id column has an index option.
- reviewed_items(id,item_id,created_at- datetime) - item_id column has an index option.
So core function of the application is "give me any items(which are not yet reviewed) for the actual moment".
How can I optimize this solution for speed(because it is very core business feature and not micro optimization)?
I suppose that adding index to the datetime fields doesn't make any sense because the cardinality or uniqueness on that fields are very high and index won't give any(?) speed-up. Is it correct?
What would you recommend? Should I try no-SQL?
--
mysql -V
5.075
I use caching where it makes sence.
© Stack Overflow or respective owner