In the previous segment, you learnt about the key performance features of Redshift. So, in this segment, you will understand the concept of SORT keys and how it helps in improving the performance of Redshift. Let’s hear more about this from our SME.
In the video above, how difficult will it be to find a particular Book, say Zenith Book, even if you know the genre?
Let’s take another scenario where you know the genre.
Initially, all books of different genres are placed into different racks which creates ambiguity because you are unable to find the desired book in minimal time. In the below video, books are differentiated by genre.
Now, since each rack is labelled with a specific genre, the time spent on searching a particular book is minimised. However, after categorising books by genre, they are still unordered, which creates difficulty in searching a particular book.
In the next video, you will learn how to sort books using the SORT key so that you can easily find the desired book.
Finally, we have sorted and arranged the books in the appropriate order. Now, you can easily find the Zenith book in minimal time.
When loading data into the table, the data will be sorted by one or more columns designated as sort keys. SORT key is a keyword to specify a single-column sort key after a column name, or you can add one or more columns as the table sort key columns using the syntax SORTKEY (column name, […]). With this syntax, only compound sort keys will be developed. If no sort keys are defined, then the list will not be sorted. You can use up to 400 SORTKEY columns per row.