All Forums Database
teradata.user 5 posts Joined 01/12
23 Mar 2012
Performance question

1. sel ...

where cast(insert_timestamp as date) = date-1


2. sel ...

where insert_timestamp = date-1

in the above 2 scenarios, in the first one, i am converting the timestamp file to date and then comparing with a date. In the 2nd case i am not converting.

Both of them work fine.

From performance point of view which is better, the first one in which we explicitly convert or in the 2nd one where we dont convert (i believe teradata does it internally). In general is it better to cast or let teradata do it ( as in some cases TD does implicit conversion) from performance point of view ?

ppad001 18 posts Joined 06/11
25 Mar 2012

You should try using the implicit datatype conversion where ever possible, if not possile you should make use of cast function.

ulrich 816 posts Joined 09/09
26 Mar 2012

Sorry no - you should go for an explicit conversion with the cast as this is documenting what you want to do - at least as long as you can't prove that the implicit conversion is significant faster!

Beside performance you need to consider code readablity and maintainability! 



cast(insert_timestamp as date) = date-1 

it is clear that date is compared to date


insert_timestamp = date-1

you don't know - as long as you really test it - if date vs. date is compared or timestamp vs. timestamp

In the later case the result would be different.

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

You must sign in to leave a comment.