I remember with Oracle up to 9 (I don't know about 10 and up) if you used a function on a column, it would not use any index that was defined on that column. Same for MS SQL Server.
I don't know PostgreSQL, but the query would actually be "date(created_at + interval '? hours')", i.e. with variable interval. Are you saying it will use the index on column +created_at+? I'd be surprised if it did. Probably with PostgreSQL you can index date(created_at) instead of just +created_at+. But as Jeremy pointed out, if you're working with time zones comparing against date(created_at) yields wrong results. Cheers, Lawrence > On 07/10/2009, at 10:54 AM, Lawrence Pit wrote: > >> Also for date(created_at + interval '10 hours') ? >> > > Why not? Don't forget that an SQL optimiser has a powerful > algebraic rewriting engine, and a decent one will find this > sort of expression trivial. That said, MySQL has a pretty > simplistic optimiser, and I don't know what it'll do. > > It's sad that MySQL is teaching the young generation that > this sort of thing matters, in fact. And it'll probably never > improve much; Oracle bought it so they could prevent it > from ever threatening their premium business. > > And people think they should adopt it because it's open > source. Phooey! > > Clifford Heath. > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en -~----------~----~----~----~------~----~------~--~---
