1
votes

I wonder if I sort my Redshift database by alphabet, it would increase the performance of look-up with the sorted column?

Let's say I have column name and I create this table sorted by alphabet. Then would it be faster if I want to look up the name with where clause?

What would be the best way to implement Redshift database for looking up alphabetic values?

And please let me know how to create table setting sort key to sort by alphabets...

Thanks

1
+1 for clearly identifying that you're using redshift not PostgreSQL. How would you create a table "sorted by" some key? Is that a redshift extension? What sort of "look-up"s are you doing - individual values, or big joins? - Craig Ringer
I would just look up individual values only in one table... And want to increase the performance by indexing the table alphabetically. I will only look up string values - user2671513
@CraigRinger Yes, sortkeys are Redshift-specific (it doesn't support other indexes beyond having a single sortkey across one or more columns). - user2303197

1 Answers

1
votes

Yes, a sortkey on the column in your WHERE clause will accelerate things generally, see here: http://docs.aws.amazon.com/redshift/latest/dg/c_best-practices-sort-key.html

If you have a sortkey on a single column, just specify the sortkey keyword after the column type (details see here: http://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_TABLE_NEW.html):

create table foo (alpha varchar(10) sortkey, bar int);