Thursday, March 29, 2018

Typecasting in SQL Could Force Database to Not Take Into Account Index or Sort Columns

DZone Database Zone
Typecasting in SQL Could Force Database to Not Take Into Account Index or Sort Columns
Typecasting in SQL Could Force Database to Not Take Into Account Index or Sort Columns

I faced this issue while working with Redshift. But it can be found in any SQL database engine.

Redshift is known as special column database that allows running queries in a parallel way to distribution and sort key. Of course, the most widely used sort key is the date and you should be really careful with it in queries. The sort key is associated only with a specific date/time format, so converting this field to any format will cause a huge drop in performance. Redshift has to convert all stored values to new format during query execution and new converted values have no sort index, so there are no advantages of the sort key.

No comments:

Fun With SQL: Functions in Postgres

DZone Database Zone Fun With SQL: Functions in Postgres In our previous  Fun with SQL  post on the  Citus Data  blog, we covered w...