id
stringlengths 14
16
| text
stringlengths 1
2.43k
| source
stringlengths 99
229
|
|---|---|---|
abc126158e23-0
|
As you have seen in the previous sections, specifying sort keys, distribution keys, and column encodings can significantly improve storage, I/O, and query performance\. This section provides a SQL script that you can run to help you identify tables where these options are missing or performing poorly\.
Copy and paste the following code to create a SQL script named `table_inspector.sql`, then execute the script in your SQL client application as superuser\.
```
SELECT SCHEMA schemaname,
"table" tablename,
table_id tableid,
size size_in_mb,
CASE
WHEN diststyle NOT IN ('EVEN','ALL') THEN 1
ELSE 0
END has_dist_key,
CASE
WHEN sortkey1 IS NOT NULL THEN 1
ELSE 0
END has_sort_key,
CASE
WHEN encoded = 'Y' THEN 1
ELSE 0
END has_col_encoding,
CAST(max_blocks_per_slice - min_blocks_per_slice AS FLOAT) / GREATEST(NVL (min_blocks_per_slice,0)::int,1) ratio_skew_across_slices,
CAST(100*dist_slice AS FLOAT) /(SELECT COUNT(DISTINCT slice) FROM stv_slices) pct_slices_populated
FROM svv_table_info ti
JOIN (SELECT tbl,
MIN(c) min_blocks_per_slice,
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/c_analyzing-table-design.md
|
abc126158e23-1
|
FROM svv_table_info ti
JOIN (SELECT tbl,
MIN(c) min_blocks_per_slice,
MAX(c) max_blocks_per_slice,
COUNT(DISTINCT slice) dist_slice
FROM (SELECT b.tbl,
b.slice,
COUNT(*) AS c
FROM STV_BLOCKLIST b
GROUP BY b.tbl,
b.slice)
WHERE tbl IN (SELECT table_id FROM svv_table_info)
GROUP BY tbl) iq ON iq.tbl = ti.table_id;
```
The following sample shows the results of running the script with two sample tables, SKEW1 and SKEW2, that demonstrate the effects of data skew\.
```
| | | |has_ |has_ |has_ |ratio_skew|pct_
| | |size_|dist_ |sort_|col_ |_across_ |slices_
schemaname|tablename|tableid|in_mb|key |key |encoding|slices |populated
----------+---------+-------+-----+------+-----+--------+----------+---------
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/c_analyzing-table-design.md
|
abc126158e23-2
|
public |category |100553 | 28 | 1 | 1 | 0 | 0 | 100
public |date |100555 | 44 | 1 | 1 | 0 | 0 | 100
public |event |100558 | 36 | 1 | 1 | 1 | 0 | 100
public |listing |100560 | 44 | 1 | 1 | 1 | 0 | 100
public |nation |100563 | 175 | 0 | 0 | 0 | 0 | 39.06
public |region |100566 | 30 | 0 | 0 | 0 | 0 | 7.81
public |sales |100562 | 52 | 1 | 1 | 0 | 0 | 100
public |skew1 |100547 |18978| 0 | 0 | 0 | .15 | 50
public |skew2 |100548 | 353 | 1 | 0 | 0 | 0 | 1.56
public |venue |100551 | 32 | 1 | 1 | 0 | 0 | 100
public |users |100549 | 82 | 1 | 1 | 1 | 0 | 100
public |venue |100551 | 32 | 1 | 1 | 0 | 0 | 100
```
The following list describes the columns in the result:
**has\_dist\_key**
Indicates whether the table has distribution key\. 1 indicates a key exists; 0 indicates there is no key\. For example, `nation` does not have a distribution key \.
**has\_sort\_key**
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/c_analyzing-table-design.md
|
abc126158e23-3
|
**has\_sort\_key**
Indicates whether the table has a sort key\. 1 indicates a key exists; 0 indicates there is no key\. For example, `nation` does not have a sort key\.
**has\_column\_encoding**
Indicates whether the table has any compression encodings defined for any of the columns\. 1 indicates at least one column has an encoding\. 0 indicates there is no encoding\. For example, `region` has no compression encoding\.
**ratio\_skew\_across\_slices**
An indication of the data distribution skew\. A smaller value is good\.
**pct\_slices\_populated**
The percentage of slices populated\. A larger value is good\.
Tables for which there is significant data distribution skew will have either a large value in the ratio\_skew\_across\_slices column or a small value in the pct\_slices\_populated column\. This indicates that you have not chosen an appropriate distribution key column\. In the example above, the SKEW1 table has a \.15 skew ratio across slices, but that's not necessarily a problem\. What's more significant is the 1\.56% value for the slices populated for the SKEW2 table\. The small value is an indication that the SKEW2 table has the wrong distribution key\.
Run the `table_inspector.sql` script whenever you add new tables to your database or whenever you have significantly modified your tables\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/c_analyzing-table-design.md
|
47153526ac6b-0
|
The following examples assign queries to queues according to user groups and query groups\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/cm-c-executing-queries.md
|
e120889ed860-0
|
If a user group name is listed in a queue definition, queries run by members of that user group are assigned to the corresponding queue\. The following example creates user groups and adds users to groups by using the SQL commands [CREATE USER](r_CREATE_USER.md), [CREATE GROUP](r_CREATE_GROUP.md), and [ALTER GROUP](r_ALTER_GROUP.md)\.
```
create group admin_group with user admin246, admin135, sec555;
create user vp1234 in group ad_hoc_group password 'vpPass1234';
alter group admin_group add user analyst44, analyst45, analyst46;
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/cm-c-executing-queries.md
|
735367add6b6-0
|
You can assign a query to a queue at runtime by assigning your query to the appropriate query group\. Use the SET command to begin a query group\.
```
SET query_group TO group_label
```
Here, **group\_label* *is a query group label that is listed in the WLM configuration\.
All queries that you run after the `SET query_group` command run as members of the specified query group until you either reset the query group or end your current login session\. For information about setting and resetting Amazon Redshift objects, see [SET](r_SET.md) and [RESET](r_RESET.md) in the SQL Command Reference\.
The query group labels that you specify must be included in the current WLM configuration; otherwise, the *SET query\_group* command has no effect on query queues\.
The label defined in the TO clause is captured in the query logs so that you can use the label for troubleshooting\. For information about the query\_group configuration parameter, see [query\_group](r_query_group.md) in the Configuration Reference\.
The following example runs two queries as part of the query group 'priority' and then resets the query group\.
```
set query_group to 'priority';
select count(*)from stv_blocklist;
select query, elapsed, substring from svl_qlog order by query desc limit 5;
reset query_group;
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/cm-c-executing-queries.md
|
e54224841dea-0
|
To assign a query to the superuser queue, log on to Amazon Redshift as a superuser and then run the query in the superuser group\. When you are done, reset the query group so that subsequent queries do not run in the superuser queue\.
The following example assigns two commands to run in the superuser queue\.
```
set query_group to 'superuser';
analyze;
vacuum;
reset query_group;
```
To view a list of superusers, query the PG\_USER system catalog table\.
```
select * from pg_user where usesuper = 'true';
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/cm-c-executing-queries.md
|
d7c30ea20c5e-0
|
The following list contains most of the valid time zone names that can be specified with the [CONVERT\_TIMEZONE function](CONVERT_TIMEZONE.md)\. For a current, complete of list time zone names, execute the following command\.
```
select pg_timezone_names();
```
Even though some of the time zone names in this list are capitalized initialisms or acronyms \(for example; GB, PRC, ROK\), the CONVERT\_TIMEZONE function treats them as time zone names, not time zone abbreviations\.
```
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
Africa/Blantyre
Africa/Brazzaville
Africa/Bujumbura
Africa/Cairo
Africa/Casablanca
Africa/Ceuta
Africa/Conakry
Africa/Dakar
Africa/Dar_es_Salaam
Africa/Djibouti
Africa/Douala
Africa/El_Aaiun
Africa/Freetown
Africa/Gaborone
Africa/Harare
Africa/Johannesburg
Africa/Juba
Africa/Kampala
Africa/Khartoum
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/time-zone-names.md
|
d7c30ea20c5e-1
|
Africa/Harare
Africa/Johannesburg
Africa/Juba
Africa/Kampala
Africa/Khartoum
Africa/Kigali
Africa/Kinshasa
Africa/Lagos
Africa/Libreville
Africa/Lome
Africa/Luanda
Africa/Lubumbashi
Africa/Lusaka
Africa/Malabo
Africa/Maputo
Africa/Maseru
Africa/Mbabane
Africa/Mogadishu
Africa/Monrovia
Africa/Nairobi
Africa/Ndjamena
Africa/Niamey
Africa/Nouakchott
Africa/Ouagadougou
Africa/Porto-Novo
Africa/Sao_Tome
Africa/Timbuktu
Africa/Tripoli
Africa/Tunis
Africa/Windhoek
America/Adak
America/Anchorage
America/Anguilla
America/Antigua
America/Araguaina
America/Argentina/Buenos_Aires
America/Argentina/Catamarca
America/Argentina/ComodRivadavia
America/Argentina/Cordoba
America/Argentina/Jujuy
America/Argentina/La_Rioja
America/Argentina/Mendoza
America/Argentina/Rio_Gallegos
America/Argentina/Salta
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/time-zone-names.md
|
d7c30ea20c5e-2
|
America/Argentina/Mendoza
America/Argentina/Rio_Gallegos
America/Argentina/Salta
America/Argentina/San_Juan
America/Argentina/San_Luis
America/Argentina/Tucuman
America/Argentina/Ushuaia
America/Aruba
America/Asuncion
America/Atikokan
America/Atka
America/Bahia
America/Bahia_Banderas
America/Barbados
America/Belem
America/Belize
America/Blanc-Sablon
America/Boa_Vista
America/Bogota
America/Boise
America/Buenos_Aires
America/Cambridge_Bay
America/Campo_Grande
America/Cancun
America/Caracas
America/Catamarca
America/Cayenne
America/Cayman
America/Chicago
America/Chihuahua
America/Coral_Harbour
America/Cordoba
America/Costa_Rica
America/Creston
America/Cuiaba
America/Curacao
America/Danmarkshavn
America/Dawson
America/Dawson_Creek
America/Denver
America/Detroit
America/Dominica
America/Edmonton
America/Eirunepe
America/El_Salvador
America/Ensenada
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/time-zone-names.md
|
d7c30ea20c5e-3
|
America/Edmonton
America/Eirunepe
America/El_Salvador
America/Ensenada
America/Fort_Wayne
America/Fortaleza
America/Glace_Bay
America/Godthab
America/Goose_Bay
America/Grand_Turk
America/Grenada
America/Guadeloupe
America/Guatemala
America/Guayaquil
America/Guyana
America/Halifax
America/Havana
America/Hermosillo
America/Indiana/Indianapolis
America/Indiana/Knox
America/Indiana/Marengo
America/Indiana/Petersburg
America/Indiana/Tell_City
America/Indiana/Vevay
America/Indiana/Vincennes
America/Indiana/Winamac
America/Indianapolis
America/Inuvik
America/Iqaluit
America/Jamaica
America/Jujuy
America/Juneau
America/Kentucky/Louisville
America/Kentucky/Monticello
America/Knox_IN
America/Kralendijk
America/La_Paz
America/Lima
America/Los_Angeles
America/Louisville
America/Lower_Princes
America/Maceio
America/Managua
America/Manaus
America/Marigot
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/time-zone-names.md
|
d7c30ea20c5e-4
|
America/Lower_Princes
America/Maceio
America/Managua
America/Manaus
America/Marigot
America/Martinique
America/Matamoros
America/Mazatlan
America/Mendoza
America/Menominee
America/Merida
America/Metlakatla
America/Mexico_City
America/Miquelon
America/Moncton
America/Monterrey
America/Montevideo
America/Montreal
America/Montserrat
America/Nassau
America/New_York
America/Nipigon
America/Nome
America/Noronha
America/North_Dakota/Beulah
America/North_Dakota/Center
America/North_Dakota/New_Salem
America/Ojinaga
America/Panama
America/Pangnirtung
America/Paramaribo
America/Phoenix
America/Port_of_Spain
America/Port-au-Prince
America/Porto_Acre
America/Porto_Velho
America/Puerto_Rico
America/Rainy_River
America/Rankin_Inlet
America/Recife
America/Regina
America/Resolute
America/Rio_Branco
America/Rosario
America/Santa_Isabel
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/time-zone-names.md
|
d7c30ea20c5e-5
|
America/Regina
America/Resolute
America/Rio_Branco
America/Rosario
America/Santa_Isabel
America/Santarem
America/Santiago
America/Santo_Domingo
America/Sao_Paulo
America/Scoresbysund
America/Shiprock
America/Sitka
America/St_Barthelemy
America/St_Johns
America/St_Kitts
America/St_Lucia
America/St_Thomas
America/St_Vincent
America/Swift_Current
America/Tegucigalpa
America/Thule
America/Thunder_Bay
America/Tijuana
America/Toronto
America/Tortola
America/Vancouver
America/Virgin
America/Whitehorse
America/Winnipeg
America/Yakutat
America/Yellowknife
Antarctica/Casey
Antarctica/Davis
Antarctica/DumontDUrville
Antarctica/Macquarie
Antarctica/Mawson
Antarctica/McMurdo
Antarctica/Palmer
Antarctica/Rothera
Antarctica/South_Pole
Antarctica/Syowa
Antarctica/Vostok
Arctic/Longyearbyen
Asia/Aden
Asia/Almaty
Asia/Amman
Asia/Anadyr
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/time-zone-names.md
|
d7c30ea20c5e-6
|
Arctic/Longyearbyen
Asia/Aden
Asia/Almaty
Asia/Amman
Asia/Anadyr
Asia/Aqtau
Asia/Aqtobe
Asia/Ashgabat
Asia/Ashkhabad
Asia/Baghdad
Asia/Bahrain
Asia/Baku
Asia/Bangkok
Asia/Beirut
Asia/Bishkek
Asia/Brunei
Asia/Calcutta
Asia/Choibalsan
Asia/Chongqing
Asia/Chungking
Asia/Colombo
Asia/Dacca
Asia/Damascus
Asia/Dhaka
Asia/Dili
Asia/Dubai
Asia/Dushanbe
Asia/Gaza
Asia/Harbin
Asia/Hebron
Asia/Ho_Chi_Minh
Asia/Hong_Kong
Asia/Hovd
Asia/Irkutsk
Asia/Istanbul
Asia/Jakarta
Asia/Jayapura
Asia/Jerusalem
Asia/Kabul
Asia/Kamchatka
Asia/Karachi
Asia/Kashgar
Asia/Kathmandu
Asia/Katmandu
Asia/Khandyga
Asia/Kolkata
Asia/Krasnoyarsk
Asia/Kuala_Lumpur
Asia/Kuching
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/time-zone-names.md
|
d7c30ea20c5e-7
|
Asia/Kolkata
Asia/Krasnoyarsk
Asia/Kuala_Lumpur
Asia/Kuching
Asia/Kuwait
Asia/Macao
Asia/Macau
Asia/Magadan
Asia/Makassar
Asia/Manila
Asia/Muscat
Asia/Nicosia
Asia/Novokuznetsk
Asia/Novosibirsk
Asia/Omsk
Asia/Oral
Asia/Phnom_Penh
Asia/Pontianak
Asia/Pyongyang
Asia/Qatar
Asia/Qyzylorda
Asia/Rangoon
Asia/Riyadh
Asia/Riyadh87
Asia/Riyadh88
Asia/Riyadh89
Asia/Saigon
Asia/Sakhalin
Asia/Samarkand
Asia/Seoul
Asia/Shanghai
Asia/Singapore
Asia/Taipei
Asia/Tashkent
Asia/Tbilisi
Asia/Tehran
Asia/Tel_Aviv
Asia/Thimbu
Asia/Thimphu
Asia/Tokyo
Asia/Ujung_Pandang
Asia/Ulaanbaatar
Asia/Ulan_Bator
Asia/Urumqi
Asia/Ust-Nera
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/time-zone-names.md
|
d7c30ea20c5e-8
|
Asia/Ulaanbaatar
Asia/Ulan_Bator
Asia/Urumqi
Asia/Ust-Nera
Asia/Vientiane
Asia/Vladivostok
Asia/Yakutsk
Asia/Yekaterinburg
Asia/Yerevan
Atlantic/Azores
Atlantic/Bermuda
Atlantic/Canary
Atlantic/Cape_Verde
Atlantic/Faeroe
Atlantic/Faroe
Atlantic/Jan_Mayen
Atlantic/Madeira
Atlantic/Reykjavik
Atlantic/South_Georgia
Atlantic/St_Helena
Atlantic/Stanley
Australia/ACT
Australia/Adelaide
Australia/Brisbane
Australia/Broken_Hill
Australia/Canberra
Australia/Currie
Australia/Darwin
Australia/Eucla
Australia/Hobart
Australia/LHI
Australia/Lindeman
Australia/Lord_Howe
Australia/Melbourne
Australia/North
Australia/NSW
Australia/Perth
Australia/Queensland
Australia/South
Australia/Sydney
Australia/Tasmania
Australia/Victoria
Australia/West
Australia/Yancowinna
Brazil/Acre
Brazil/DeNoronha
Brazil/East
Brazil/West
Canada/Atlantic
Canada/Central
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/time-zone-names.md
|
d7c30ea20c5e-9
|
Brazil/DeNoronha
Brazil/East
Brazil/West
Canada/Atlantic
Canada/Central
Canada/Eastern
Canada/East-Saskatchewan
Canada/Mountain
Canada/Newfoundland
Canada/Pacific
Canada/Saskatchewan
Canada/Yukon
CET
Chile/Continental
Chile/EasterIsland
CST6CDT
Cuba
EET
Egypt
Eire
EST
EST5EDT
Etc/GMT
Etc/GMT+0
Etc/GMT+1
Etc/GMT+10
Etc/GMT+11
Etc/GMT+12
Etc/GMT+2
Etc/GMT+3
Etc/GMT+4
Etc/GMT+5
Etc/GMT+6
Etc/GMT+7
Etc/GMT+8
Etc/GMT+9
Etc/GMT0
Etc/GMT-0
Etc/GMT-1
Etc/GMT-10
Etc/GMT-11
Etc/GMT-12
Etc/GMT-13
Etc/GMT-14
Etc/GMT-2
Etc/GMT-3
Etc/GMT-4
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/time-zone-names.md
|
d7c30ea20c5e-10
|
Etc/GMT-14
Etc/GMT-2
Etc/GMT-3
Etc/GMT-4
Etc/GMT-5
Etc/GMT-6
Etc/GMT-7
Etc/GMT-8
Etc/GMT-9
Etc/Greenwich
Etc/UCT
Etc/Universal
Etc/UTC
Etc/Zulu
Europe/Amsterdam
Europe/Andorra
Europe/Athens
Europe/Belfast
Europe/Belgrade
Europe/Berlin
Europe/Bratislava
Europe/Brussels
Europe/Bucharest
Europe/Budapest
Europe/Busingen
Europe/Chisinau
Europe/Copenhagen
Europe/Dublin
Europe/Gibraltar
Europe/Guernsey
Europe/Helsinki
Europe/Isle_of_Man
Europe/Istanbul
Europe/Jersey
Europe/Kaliningrad
Europe/Kiev
Europe/Lisbon
Europe/Ljubljana
Europe/London
Europe/Luxembourg
Europe/Madrid
Europe/Malta
Europe/Mariehamn
Europe/Minsk
Europe/Monaco
Europe/Moscow
Europe/Nicosia
Europe/Oslo
Europe/Paris
Europe/Podgorica
Europe/Prague
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/time-zone-names.md
|
d7c30ea20c5e-11
|
Europe/Nicosia
Europe/Oslo
Europe/Paris
Europe/Podgorica
Europe/Prague
Europe/Riga
Europe/Rome
Europe/Samara
Europe/San_Marino
Europe/Sarajevo
Europe/Simferopol
Europe/Skopje
Europe/Sofia
Europe/Stockholm
Europe/Tallinn
Europe/Tirane
Europe/Tiraspol
Europe/Uzhgorod
Europe/Vaduz
Europe/Vatican
Europe/Vienna
Europe/Vilnius
Europe/Volgograd
Europe/Warsaw
Europe/Zagreb
Europe/Zaporozhye
Europe/Zurich
GB
GB-Eire
GMT
GMT+0
GMT0
GMT-0
Greenwich
Hongkong
HST
Iceland
Indian/Antananarivo
Indian/Chagos
Indian/Christmas
Indian/Cocos
Indian/Comoro
Indian/Kerguelen
Indian/Mahe
Indian/Maldives
Indian/Mauritius
Indian/Mayotte
Indian/Reunion
Iran
Israel
Jamaica
Japan
Kwajalein
Libya
MET
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/time-zone-names.md
|
d7c30ea20c5e-12
|
Iran
Israel
Jamaica
Japan
Kwajalein
Libya
MET
Mexico/BajaNorte
Mexico/BajaSur
Mexico/General
Mideast/Riyadh87
Mideast/Riyadh88
Mideast/Riyadh89
MST
MST7MDT
Navajo
NZ
NZ-CHAT
Pacific/Apia
Pacific/Auckland
Pacific/Chatham
Pacific/Chuuk
Pacific/Easter
Pacific/Efate
Pacific/Enderbury
Pacific/Fakaofo
Pacific/Fiji
Pacific/Funafuti
Pacific/Galapagos
Pacific/Gambier
Pacific/Guadalcanal
Pacific/Guam
Pacific/Honolulu
Pacific/Johnston
Pacific/Kiritimati
Pacific/Kosrae
Pacific/Kwajalein
Pacific/Majuro
Pacific/Marquesas
Pacific/Midway
Pacific/Nauru
Pacific/Niue
Pacific/Norfolk
Pacific/Noumea
Pacific/Pago_Pago
Pacific/Palau
Pacific/Pitcairn
Pacific/Pohnpei
Pacific/Ponape
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/time-zone-names.md
|
d7c30ea20c5e-13
|
Pacific/Palau
Pacific/Pitcairn
Pacific/Pohnpei
Pacific/Ponape
Pacific/Port_Moresby
Pacific/Rarotonga
Pacific/Saipan
Pacific/Samoa
Pacific/Tahiti
Pacific/Tarawa
Pacific/Tongatapu
Pacific/Truk
Pacific/Wake
Pacific/Wallis
Pacific/Yap
Poland
Portugal
PRC
PST8PDT
ROK
Singapore
Turkey
UCT
Universal
US/Alaska
US/Aleutian
US/Arizona
US/Central
US/Eastern
US/East-Indiana
US/Hawaii
US/Indiana-Starke
US/Michigan
US/Mountain
US/Pacific
US/Pacific-New
US/Samoa
UTC
WET
W-SU
Zulu
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/time-zone-names.md
|
88bd3c075593-0
|
You can unload data in delimited format or fixed\-width format\. The default output is pipe\-delimited \(using the '\|' character\)\.
The following example specifies a comma as the delimiter:
```
unload ('select * from venue')
to 's3://mybucket/tickit/venue/comma'
iam_role 'arn:aws:iam::0123456789012:role/MyRedshiftRole'
delimiter ',';
```
The resulting output files look like this:
```
20,Air Canada Centre,Toronto,ON,0
60,Rexall Place,Edmonton,AB,0
100,U.S. Cellular Field,Chicago,IL,40615
200,Al Hirschfeld Theatre,New York City,NY,0
240,San Jose Repertory Theatre,San Jose,CA,0
300,Kennedy Center Opera House,Washington,DC,0
...
```
To unload the same result set to a tab\-delimited file, issue the following command:
```
unload ('select * from venue')
to 's3://mybucket/tickit/venue/tab'
iam_role 'arn:aws:iam::0123456789012:role/MyRedshiftRole'
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/t_unloading_fixed_width_data.md
|
88bd3c075593-1
|
iam_role 'arn:aws:iam::0123456789012:role/MyRedshiftRole'
delimiter as '\t';
```
Alternatively, you can use a FIXEDWIDTH specification\. This specification consists of an identifier for each table column and the width of the column \(number of characters\)\. The UNLOAD command will fail rather than truncate data, so specify a width that is at least as long as the longest entry for that column\. Unloading fixed\-width data works similarly to unloading delimited data, except that the resulting output contains no delimiting characters\. For example:
```
unload ('select * from venue')
to 's3://mybucket/tickit/venue/fw'
iam_role 'arn:aws:iam::0123456789012:role/MyRedshiftRole'
fixedwidth '0:3,1:100,2:30,3:2,4:6';
```
The fixed\-width output looks like this:
```
20 Air Canada Centre Toronto ON0
60 Rexall Place Edmonton AB0
100U.S. Cellular Field Chicago IL40615
200Al Hirschfeld Theatre New York CityNY0
240San Jose Repertory TheatreSan Jose CA0
300Kennedy Center Opera HouseWashington DC0
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/t_unloading_fixed_width_data.md
|
88bd3c075593-2
|
240San Jose Repertory TheatreSan Jose CA0
300Kennedy Center Opera HouseWashington DC0
```
For more details about FIXEDWIDTH specifications, see the [UNLOAD](r_UNLOAD.md) command\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/t_unloading_fixed_width_data.md
|
84b0419b6f2e-0
|
Analyzes hash join execution steps for queries\.
This view is visible to all users\. Superusers can see all rows; regular users can see only their own data\. For more information, see [Visibility of data in system tables and views](c_visibility-of-data.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_STL_HASHJOIN.md
|
25464de4f54c-0
|
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_STL_HASHJOIN.html)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_STL_HASHJOIN.md
|
d65672c1a8a6-0
|
The following example returns the number of partitions used in a hash join for query 720\.
```
select query, slice, tbl, num_parts
from stl_hashjoin
where query=720 limit 10;
```
```
query | slice | tbl | num_parts
-------+-------+-----+-----------
720 | 0 | 243 | 1
720 | 1 | 243 | 1
(2 rows)
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_STL_HASHJOIN.md
|
c369e150acad-0
|
ST\_Length2D is an alias for ST\_Length\. For more information, see [ST\_Length](ST_Length-function.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/ST_Length2D-function.md
|
07f8e1876bfc-0
|
Amazon Redshift automatically loads in parallel from multiple data files\.
If you use multiple concurrent COPY commands to load one table from multiple files, Amazon Redshift is forced to perform a serialized load\. This type of load is much slower and requires a VACUUM process at the end if the table has a sort column defined\. For more information about using COPY to load data in parallel, see [Loading data from Amazon S3](t_Loading-data-from-S3.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/c_best-practices-single-copy-command.md
|
596044e124ca-0
|
Amazon Redshift Spectrum supports querying nested data in Parquet, ORC, JSON, and Ion file formats\. Redshift Spectrum accesses the data using external tables\. You can create external tables that use the complex data types `struct`, `array`, and `map`\.
For example, suppose that your data file contains the following data in Amazon S3 in a folder named `customers`\. Although there isn't a single root element, each JSON object in this sample data represents a row in a table\.
```
{"id": 1,
"name": {"given": "John", "family": "Smith"},
"phones": ["123-457789"],
"orders": [{"shipdate": "2018-03-01T11:59:59.000Z", "price": 100.50},
{"shipdate": "2018-03-01T09:10:00.000Z", "price": 99.12}]
}
{"id": 2,
"name": {"given": "Jenny", "family": "Doe"},
"phones": ["858-8675309", "415-9876543"],
"orders": []
}
{"id": 3,
"name": {"given": "Andy", "family": "Jones"},
"phones": [],
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/tutorial-query-nested-data.md
|
596044e124ca-1
|
"name": {"given": "Andy", "family": "Jones"},
"phones": [],
"orders": [{"shipdate": "2018-03-02T08:02:15.000Z", "price": 13.50}]
}
```
You can use Redshift Spectrum to query this data\. The following tutorial shows you how to do so\.
For tutorial prerequisites, steps, and nested data use cases, see the following topics:
+ [Prerequisites](#tutorial-nested-data-prereq)
+ [Step 1: Create an external table that contains nested data](tutorial-nested-data-create-table.md)
+ [Step 2: Query your nested data in Amazon S3 with SQL extensions](tutorial-query-nested-data-sqlextensions.md)
+ [Nested data use cases ](nested-data-use-cases.md)
+ [Nested data limitations](nested-data-restrictions.md)
+ [Serializing complex nested JSON](serializing-complex-JSON.md)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/tutorial-query-nested-data.md
|
ecead4920f11-0
|
If you are not using Redshift Spectrum yet, follow the steps in the [Getting started with Amazon Redshift Spectrum](c-getting-started-using-spectrum.md) tutorial before continuing\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/tutorial-query-nested-data.md
|
7ba855f79ff2-0
|
The following Amazon Redshift system tables can be helpful in troubleshooting data load issues:
+ Query [STL\_LOAD\_ERRORS](r_STL_LOAD_ERRORS.md) to discover the errors that occurred during specific loads\.
+ Query [STL\_FILE\_SCAN](r_STL_FILE_SCAN.md) to view load times for specific files or to see if a specific file was even read\.
+ Query [STL\_S3CLIENT\_ERROR](r_STL_S3CLIENT_ERROR.md) to find details for errors encountered while transferring data from Amazon S3\.
**To find and diagnose load errors**
1. Create a view or define a query that returns details about load errors\. The following example joins the STL\_LOAD\_ERRORS table to the STV\_TBL\_PERM table to match table IDs with actual table names\.
```
create view loadview as
(select distinct tbl, trim(name) as table_name, query, starttime,
trim(filename) as input, line_number, colname, err_code,
trim(err_reason) as reason
from stl_load_errors sl, stv_tbl_perm sp
where sl.tbl = sp.id);
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/system-tables-for-troubleshooting-data-loads.md
|
7ba855f79ff2-1
|
where sl.tbl = sp.id);
```
1. Set the MAXERRORS option in your COPY command to a large enough value to enable COPY to return useful information about your data\. If the COPY encounters errors, an error message directs you to consult the STL\_LOAD\_ERRORS table for details\.
1. Query the LOADVIEW view to see error details\. For example:
```
select * from loadview where table_name='venue';
```
```
tbl | table_name | query | starttime
--------+------------+-------+----------------------------
100551 | venue | 20974 | 2013-01-29 19:05:58.365391
| input | line_number | colname | err_code | reason
+----------------+-------------+-------+----------+---------------------
| venue_pipe.txt | 1 | 0 | 1214 | Delimiter not found
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/system-tables-for-troubleshooting-data-loads.md
|
7ba855f79ff2-2
|
| venue_pipe.txt | 1 | 0 | 1214 | Delimiter not found
```
1. Fix the problem in the input file or the load script, based on the information that the view returns\. Some typical load errors to watch for include:
+ Mismatch between data types in table and values in input data fields\.
+ Mismatch between number of columns in table and number of fields in input data\.
+ Mismatched quotes\. Amazon Redshift supports both single and double quotes; however, these quotes must be balanced appropriately\.
+ Incorrect format for date/time data in input files\.
+ Out\-of\-range values in input files \(for numeric columns\)\.
+ Number of distinct values for a column exceeds the limitation for its compression encoding\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/system-tables-for-troubleshooting-data-loads.md
|
37117241b3b2-0
|
Contains the current state of the service classes\.
STV\_WLM\_SERVICE\_CLASS\_STATE is visible only to superusers\. For more information, see [Visibility of data in system tables and views](c_visibility-of-data.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_STV_WLM_SERVICE_CLASS_STATE.md
|
60e646009b43-0
|
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_STV_WLM_SERVICE_CLASS_STATE.html)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_STV_WLM_SERVICE_CLASS_STATE.md
|
ac36e20fc3d3-0
|
The following query displays the state for service classes greater than 5\. For a list of service class IDs, see [WLM service class IDs](cm-c-wlm-system-tables-and-views.md#wlm-service-class-ids)\.
```
select service_class, num_executing_queries,
num_executed_queries
from stv_wlm_service_class_state
where service_class > 5
order by service_class;
```
```
service_class | num_executing_queries | num_executed_queries
---------------+-----------------------+----------------------
6 | 1 | 222
7 | 0 | 135
8 | 1 | 39
(3 rows)
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_STV_WLM_SERVICE_CLASS_STATE.md
|
f1a7ed89e804-0
|
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_salestable.html)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_salestable.md
|
51e37450269c-0
|
**Topics**
+ [Time zone names](time-zone-names.md)
+ [Time zone abbreviations](time-zone-abbrevs.md)
The following lists contain most of the valid time zone names and time zone abbreviations that can be specified with the [CONVERT\_TIMEZONE function](CONVERT_TIMEZONE.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/appendix-timezone-names.md
|
a02bfbc423ae-0
|
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_listingtable.html)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_listingtable.md
|
7d7f2e1fd933-0
|
The following example uses a UNION ALL operator because duplicate rows, if found, need to be retained in the result\. For a specific series of event IDs, the query returns 0 or more rows for each sale associated with each event, and 0 or 1 row for each listing of that event\. Event IDs are unique to each row in the LISTING and EVENT tables, but there might be multiple sales for the same combination of event and listing IDs in the SALES table\.
The third column in the result set identifies the source of the row\. If it comes from the SALES table, it is marked "Yes" in the SALESROW column\. \(SALESROW is an alias for SALES\.LISTID\.\) If the row comes from the LISTING table, it is marked "No" in the SALESROW column\.
In this case, the result set consists of three sales rows for listing 500, event 7787\. In other words, three different transactions took place for this listing and event combination\. The other two listings, 501 and 502, did not produce any sales, so the only row that the query produces for these list IDs comes from the LISTING table \(SALESROW = 'No'\)\.
```
select eventid, listid, 'Yes' as salesrow
from sales
where listid in(500,501,502)
union all
select eventid, listid, 'No'
from listing
where listid in(500,501,502)
order by listid asc;
eventid | listid | salesrow
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/c_example_unionall_query.md
|
7d7f2e1fd933-1
|
where listid in(500,501,502)
order by listid asc;
eventid | listid | salesrow
---------+--------+----------
7787 | 500 | No
7787 | 500 | Yes
7787 | 500 | Yes
7787 | 500 | Yes
6473 | 501 | No
5108 | 502 | No
(6 rows)
```
If you run the same query without the ALL keyword, the result retains only one of the sales transactions\.
```
select eventid, listid, 'Yes' as salesrow
from sales
where listid in(500,501,502)
union
select eventid, listid, 'No'
from listing
where listid in(500,501,502)
order by listid asc;
eventid | listid | salesrow
---------+--------+----------
7787 | 500 | No
7787 | 500 | Yes
6473 | 501 | No
5108 | 502 | No
(4 rows)
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/c_example_unionall_query.md
|
4b5d5fa9af9f-0
|
Use the BOOLEAN data type to store true and false values in a single\-byte column\. The following table describes the three possible states for a Boolean value and the literal values that result in that state\. Regardless of the input string, a Boolean column stores and outputs "t" for true and "f" for false\.
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_Boolean_type.html)
You can use an IS comparison to check a Boolean value only as a predicate in the WHERE clause\. You can't use the IS comparison with a Boolean value in the SELECT list\.
**Note**
We recommend always checking Boolean values explicitly, as shown in the examples following\. Implicit comparisons, such as `WHERE flag` or `WHERE NOT flag` might return unexpected results\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_Boolean_type.md
|
dadc698c5caf-0
|
You could use a BOOLEAN column to store an "Active/Inactive" state for each customer in a CUSTOMER table\.
```
create table customer(
custid int,
active_flag boolean default true);
```
```
insert into customer values(100, default);
```
```
select * from customer;
custid | active_flag
-------+--------------
100 | t
```
If no default value \(`true` or `false`\) is specified in the CREATE TABLE statement, inserting a default value means inserting a null\.
In this example, the query selects users from the USERS table who like sports but do not like theatre:
```
select firstname, lastname, likesports, liketheatre
from users
where likesports is true and liketheatre is false
order by userid limit 10;
firstname | lastname | likesports | liketheatre
----------+------------+------------+-------------
Lars | Ratliff | t | f
Mufutau | Watkins | t | f
Scarlett | Mayer | t | f
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_Boolean_type.md
|
dadc698c5caf-1
|
Lars | Ratliff | t | f
Mufutau | Watkins | t | f
Scarlett | Mayer | t | f
Shafira | Glenn | t | f
Winifred | Cherry | t | f
Chase | Lamb | t | f
Liberty | Ellison | t | f
Aladdin | Haney | t | f
Tashya | Michael | t | f
Lucian | Montgomery | t | f
(10 rows)
```
The following example selects users from the USERS table for whom is it unknown whether they like rock music\.
```
select firstname, lastname, likerock
from users
where likerock is unknown
order by userid limit 10;
firstname | lastname | likerock
----------+----------+----------
Rafael | Taylor |
Vladimir | Humphrey |
Barry | Roy |
Tamekah | Juarez |
Mufutau | Watkins |
Naida | Calderon |
Anika | Huff |
Bruce | Beck |
Mallory | Farrell |
Scarlett | Mayer |
(10 rows)
```
The following example returns an error because it uses an IS comparison in the SELECT list\.
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_Boolean_type.md
|
dadc698c5caf-2
|
```
The following example returns an error because it uses an IS comparison in the SELECT list\.
```
select firstname, lastname, likerock is true as "check"
from users
order by userid limit 10;
[Amazon](500310) Invalid operation: Not implemented
```
The following example succeeds because it uses an equal comparison \( = \) in the SELECT list instead of the IS comparison\.
```
select firstname, lastname, likerock = true as "check"
from users
order by userid limit 10;
firstname | lastname | check
----------+-----------+------
Rafael | Taylor |
Vladimir | Humphrey |
Lars | Ratliff | true
Barry | Roy |
Reagan | Hodge | true
Victor | Hernandez | true
Tamekah | Juarez |
Colton | Roy | false
Mufutau | Watkins |
Naida | Calderon |
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_Boolean_type.md
|
5a4ac294216e-0
|
These functions prepend or append characters to a string, based on a specified length\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_LPAD.md
|
1ca21da2747f-0
|
```
LPAD (string1, length, [ string2 ])
```
```
RPAD (string1, length, [ string2 ])
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_LPAD.md
|
d18370acc1c6-0
|
*string1*
A character string or an expression that evaluates to a character string, such as the name of a character column\.
*length*
An integer that defines the length of the result of the function\. The length of a string is based on the number of characters, not bytes, so that multi\-byte characters are counted as single characters\. If *string1* is longer than the specified length, it is truncated \(on the right\)\. If *length* is a negative number, the result of the function is an empty string\.
*string2*
One or more characters that are prepended or appended to *string1*\. This argument is optional; if it is not specified, spaces are used\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_LPAD.md
|
581dad257768-0
|
These functions return a VARCHAR data type\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_LPAD.md
|
e6861100e48a-0
|
Truncate a specified set of event names to 20 characters and prepend the shorter names with spaces:
```
select lpad(eventname,20) from event
where eventid between 1 and 5 order by 1;
lpad
--------------------
Salome
Il Trovatore
Boris Godunov
Gotterdammerung
La Cenerentola (Cind
(5 rows)
```
Truncate the same set of event names to 20 characters but append the shorter names with `0123456789`\.
```
select rpad(eventname,20,'0123456789') from event
where eventid between 1 and 5 order by 1;
rpad
--------------------
Boris Godunov0123456
Gotterdammerung01234
Il Trovatore01234567
La Cenerentola (Cind
Salome01234567890123
(5 rows)
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_LPAD.md
|
081f7e741de6-0
|
Amazon Redshift stores DATE and TIMESTAMP data more efficiently than CHAR or VARCHAR, which results in better query performance\. Use the DATE or TIMESTAMP data type, depending on the resolution you need, rather than a character type when storing date/time information\. For more information, see [Datetime types](r_Datetime_types.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/c_best-practices-timestamp-date-columns.md
|
1ed2756da07a-0
|
You can use the COPY command to load a table with data from a single Amazon DynamoDB table\.
**Important**
The Amazon DynamoDB table that provides the data must be created in the same AWS Region as your cluster unless you use the [REGION](copy-parameters-data-source-s3.md#copy-region) option to specify the AWS Region in which the Amazon DynamoDB table is located\.
The COPY command leverages the Amazon Redshift massively parallel processing \(MPP\) architecture to read and load data in parallel from an Amazon DynamoDB table\. You can take maximum advantage of parallel processing by setting distribution styles on your Amazon Redshift tables\. For more information, see [Choosing a data distribution style](t_Distributing_data.md)\.
**Important**
When the COPY command reads data from the Amazon DynamoDB table, the resulting data transfer is part of that table's provisioned throughput\.
To avoid consuming excessive amounts of provisioned read throughput, we recommend that you not load data from Amazon DynamoDB tables that are in production environments\. If you do load data from production tables, we recommend that you set the READRATIO option much lower than the average percentage of unused provisioned throughput\. A low READRATIO setting will help minimize throttling issues\. To use the entire provisioned throughput of an Amazon DynamoDB table, set READRATIO to 100\.
The COPY command matches attribute names in the items retrieved from the DynamoDB table to column names in an existing Amazon Redshift table by using the following rules:
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/t_Loading-data-from-dynamodb.md
|
1ed2756da07a-1
|
The COPY command matches attribute names in the items retrieved from the DynamoDB table to column names in an existing Amazon Redshift table by using the following rules:
+ Amazon Redshift table columns are case\-insensitively matched to Amazon DynamoDB item attributes\. If an item in the DynamoDB table contains multiple attributes that differ only in case, such as Price and PRICE, the COPY command will fail\.
+ Amazon Redshift table columns that do not match an attribute in the Amazon DynamoDB table are loaded as either NULL or empty, depending on the value specified with the EMPTYASNULL option in the [COPY](r_COPY.md) command\.
+ Amazon DynamoDB attributes that do not match a column in the Amazon Redshift table are discarded\. Attributes are read before they are matched, and so even discarded attributes consume part of that table's provisioned throughput\.
+ Only Amazon DynamoDB attributes with scalar STRING and NUMBER data types are supported\. The Amazon DynamoDB BINARY and SET data types are not supported\. If a COPY command tries to load an attribute with an unsupported data type, the command will fail\. If the attribute does not match an Amazon Redshift table column, COPY does not attempt to load it, and it does not raise an error\.
The COPY command uses the following syntax to load data from an Amazon DynamoDB table:
```
copy <redshift_tablename> from 'dynamodb://<dynamodb_table_name>'
authorization
readratio '<integer>';
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/t_Loading-data-from-dynamodb.md
|
1ed2756da07a-2
|
authorization
readratio '<integer>';
```
The values for *authorization* are the AWS credentials needed to access the Amazon DynamoDB table\. If these credentials correspond to an IAM user, that IAM user must have permission to SCAN and DESCRIBE the Amazon DynamoDB table that is being loaded\.
The values for *authorization* provide the AWS authorization your cluster needs to access the Amazon DynamoDB table\. The permission must include SCAN and DESCRIBE for the Amazon DynamoDB table that is being loaded\. For more information about required permissions, see [IAM permissions for COPY, UNLOAD, and CREATE LIBRARY](copy-usage_notes-access-permissions.md#copy-usage_notes-iam-permissions)\. The preferred method for authentication is to specify the IAM\_ROLE parameter and provide the Amazon Resource Name \(ARN\) for an IAM role with the necessary permissions\. Alternatively, you can specify the ACCESS\_KEY\_ID and SECRET\_ACCESS\_KEY parameters and provide the access key ID and secret access key for an authorized IAM user as plain text\. For more information, see [Role\-based access control](copy-usage_notes-access-permissions.md#copy-usage_notes-access-role-based) or [Key\-based access control](copy-usage_notes-access-permissions.md#copy-usage_notes-access-key-based)\.
To authenticate using the IAM\_ROLE parameter, *<aws\-account\-id>* and *<role\-name>* as shown in the following syntax\.
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/t_Loading-data-from-dynamodb.md
|
1ed2756da07a-3
|
```
IAM_ROLE 'arn:aws:iam::<aws-account-id>:role/<role-name>'
```
The following example shows authentication using an IAM role\.
```
copy favoritemovies
from 'dynamodb://ProductCatalog'
iam_role 'arn:aws:iam::0123456789012:role/MyRedshiftRole';
```
To authenticate using IAM user credentials, replace *<access\-key\-id>* and *<secret\-access\-key* with an authorized user's access key ID and full secret access key for the ACCESS\_KEY\_ID and SECRET\_ACCESS\_KEY parameters as shown following\.
```
ACCESS_KEY_ID '<access-key-id>'
SECRET_ACCESS_KEY '<secret-access-key>';
```
The following example shows authentication using IAM user credentials\.
```
copy favoritemovies
from 'dynamodb://ProductCatalog'
access_key_id '<access-key-id>'
secret_access_key '<secret-access-key';
```
For more information about other authorization options, see [Authorization parameters](copy-parameters-authorization.md)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/t_Loading-data-from-dynamodb.md
|
1ed2756da07a-4
|
```
For more information about other authorization options, see [Authorization parameters](copy-parameters-authorization.md)
If you want to validate your data without actually loading the table, use the NOLOAD option with the [COPY](r_COPY.md) command\.
The following example loads the FAVORITEMOVIES table with data from the DynamoDB table my\-favorite\-movies\-table\. The read activity can consume up to 50% of the provisioned throughput\.
```
copy favoritemovies from 'dynamodb://my-favorite-movies-table'
iam_role 'arn:aws:iam::0123456789012:role/MyRedshiftRole'
readratio 50;
```
To maximize throughput, the COPY command loads data from an Amazon DynamoDB table in parallel across the compute nodes in the cluster\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/t_Loading-data-from-dynamodb.md
|
c1007423c4eb-0
|
By default, the COPY command applies automatic compression whenever you specify an empty target table with no compression encoding\. The automatic compression analysis initially samples a large number of rows from the Amazon DynamoDB table\. The sample size is based on the value of the COMPROWS parameter\. The default is 100,000 rows per slice\.
After sampling, the sample rows are discarded and the entire table is loaded\. As a result, many rows are read twice\. For more information about how automatic compression works, see [Loading tables with automatic compression](c_Loading_tables_auto_compress.md)\.
**Important**
When the COPY command reads data from the Amazon DynamoDB table, including the rows used for sampling, the resulting data transfer is part of that table's provisioned throughput\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/t_Loading-data-from-dynamodb.md
|
8da08824417b-0
|
If your data includes non\-ASCII multibyte characters \(such as Chinese or Cyrillic characters\), you must load the data to VARCHAR columns\. The VARCHAR data type supports four\-byte UTF\-8 characters, but the CHAR data type only accepts single\-byte ASCII characters\. You cannot load five\-byte or longer characters into Amazon Redshift tables\. For more information about CHAR and VARCHAR, see [Data types](c_Supported_data_types.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/t_Loading-data-from-dynamodb.md
|
1c1c95c017a5-0
|
**Topics**
+ [Integer types](#r_Numeric_types201-integer-types)
+ [DECIMAL or NUMERIC type](#r_Numeric_types201-decimal-or-numeric-type)
+ [Notes about using 128\-bit DECIMAL or NUMERIC columns](#r_Numeric_types201-notes-about-using-128-bit-decimal-or-numeric-columns)
+ [Floating\-Point types](#r_Numeric_types201-floating-point-types)
+ [Computations with numeric values](r_numeric_computations201.md)
+ [Integer and floating\-point literals](r_numeric_literals201.md)
+ [Examples with numeric types](r_Examples_with_numeric_types201.md)
Numeric data types include integers, decimals, and floating\-point numbers\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_Numeric_types201.md
|
10d5ad6ea550-0
|
Use the SMALLINT, INTEGER, and BIGINT data types to store whole numbers of various ranges\. You cannot store values outside of the allowed range for each type\.
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_Numeric_types201.html)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_Numeric_types201.md
|
0ac23803ec0e-0
|
Use the DECIMAL or NUMERIC data type to store values with a *user\-defined precision*\. The DECIMAL and NUMERIC keywords are interchangeable\. In this document, *decimal* is the preferred term for this data type\. The term *numeric* is used generically to refer to integer, decimal, and floating\-point data types\.
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_Numeric_types201.html)
Define a DECIMAL column in a table by specifying a *precision* and *scale*:
```
decimal(precision, scale)
```
*precision*
The total number of significant digits in the whole value: the number of digits on both sides of the decimal point\. For example, the number `48.2891` has a precision of 6 and a scale of 4\. The default precision, if not specified, is 18\. The maximum precision is 38\.
If the number of digits to the left of the decimal point in an input value exceeds the precision of the column minus its scale, the value cannot be copied into the column \(or inserted or updated\)\. This rule applies to any value that falls outside the range of the column definition\. For example, the allowed range of values for a `numeric(5,2)` column is `-999.99` to `999.99`\.
*scale*
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_Numeric_types201.md
|
0ac23803ec0e-1
|
*scale*
The number of decimal digits in the fractional part of the value, to the right of the decimal point\. Integers have a scale of zero\. In a column specification, the scale value must be less than or equal to the precision value\. The default scale, if not specified, is 0\. The maximum scale is 37\.
If the scale of an input value that is loaded into a table is greater than the scale of the column, the value is rounded to the specified scale\. For example, the PRICEPAID column in the SALES table is a DECIMAL\(8,2\) column\. If a DECIMAL\(8,4\) value is inserted into the PRICEPAID column, the value is rounded to a scale of 2\.
```
insert into sales
values (0, 8, 1, 1, 2000, 14, 5, 4323.8951, 11.00, null);
select pricepaid, salesid from sales where salesid=0;
pricepaid | salesid
-----------+---------
4323.90 | 0
(1 row)
```
However, results of explicit casts of values selected from tables are not rounded\.
**Note**
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_Numeric_types201.md
|
0ac23803ec0e-2
|
```
However, results of explicit casts of values selected from tables are not rounded\.
**Note**
The maximum positive value that you can insert into a DECIMAL\(19,0\) column is `9223372036854775807` \(263 \-1\)\. The maximum negative value is `-9223372036854775807`\. For example, an attempt to insert the value `9999999999999999999` \(19 nines\) will cause an overflow error\. Regardless of the placement of the decimal point, the largest string that Amazon Redshift can represent as a DECIMAL number is `9223372036854775807`\. For example, the largest value that you can load into a DECIMAL\(19,18\) column is `9.223372036854775807`\. These rules derive from the internal storage of DECIMAL values as 8\-byte integers\. Amazon Redshift recommends that you do not define DECIMAL values with 19 digits of precision unless that precision is necessary\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_Numeric_types201.md
|
f6c7485de18b-0
|
Do not arbitrarily assign maximum precision to DECIMAL columns unless you are certain that your application requires that precision\. 128\-bit values use twice as much disk space as 64\-bit values and can slow down query execution time\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_Numeric_types201.md
|
5633801297ef-0
|
Use the REAL and DOUBLE PRECISION data types to store numeric values with *variable precision*\. These types are *inexact* types, meaning that some values are stored as approximations, such that storing and returning a specific value may result in slight discrepancies\. If you require exact storage and calculations \(such as for monetary amounts\), use the DECIMAL data type\.
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/r_Numeric_types201.html)
For example, note the results of the following inserts into a REAL column:
```
create table real1(realcol real);
insert into real1 values(12345.12345);
insert into real1 values(123456.12345);
select * from real1;
realcol
---------
123456
12345.1
(2 rows)
```
These inserted values are truncated to meet the limitation of 6 significant digits of precision for REAL columns\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_Numeric_types201.md
|
e31f9e84989e-0
|
Drops a database\.
You can't run DROP DATABASE within a transaction block \(BEGIN \.\.\. END\)\. For more information about transactions, see [Serializable isolation](c_serial_isolation.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_DROP_DATABASE.md
|
287843b5d9bd-0
|
```
DROP DATABASE database_name
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_DROP_DATABASE.md
|
c27537907b12-0
|
*database\_name*
Name of the database to be dropped\. You can't drop the dev, padb\_harvest, template0, or template1 databases, and you can't drop the current database\.
To drop an external database, drop the external schema\. For more information, see [DROP SCHEMA](r_DROP_SCHEMA.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_DROP_DATABASE.md
|
f051e2970198-0
|
The following example drops a database named TICKIT\_TEST:
```
drop database tickit_test;
```
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/r_DROP_DATABASE.md
|
756c8b88d429-0
|
Before you start to configure manual WLM, it’s useful to understand the default behavior of queue processing in Amazon Redshift\. In this section, you create two database views that return information from several system tables\. Then you run some test queries to see how queries are routed by default\. For more information about system tables, see [System tables reference](cm_chap_system-tables.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/tutorial-wlm-understanding-default-processing.md
|
4b3bca29d2eb-0
|
In this step, you create a view called WLM\_QUEUE\_STATE\_VW\. This view returns information from the following system tables\.
+ [STV\_WLM\_CLASSIFICATION\_CONFIG](r_STV_WLM_CLASSIFICATION_CONFIG.md)
+ [STV\_WLM\_SERVICE\_CLASS\_CONFIG](r_STV_WLM_SERVICE_CLASS_CONFIG.md)
+ [STV\_WLM\_SERVICE\_CLASS\_STATE](r_STV_WLM_SERVICE_CLASS_STATE.md)
You use this view throughout the tutorial to monitor what happens to queues after you change the WLM configuration\. The following table describes the data that the WLM\_QUEUE\_STATE\_VW view returns\.
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/tutorial-wlm-understanding-default-processing.html)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/tutorial-wlm-understanding-default-processing.md
|
9a576043bb07-0
|
1. Open psql and connect to your TICKIT sample database\. If you do not have this database, see [Prerequisites](tutorial-configuring-workload-management.md#tutorial-wlm-prereq)\.
1. Run the following query to create the WLM\_QUEUE\_STATE\_VW view\.
```
create view WLM_QUEUE_STATE_VW as
select (config.service_class-5) as queue
, trim (class.condition) as description
, config.num_query_tasks as slots
, config.query_working_mem as mem
, config.max_execution_time as max_time
, config.user_group_wild_card as "user_*"
, config.query_group_wild_card as "query_*"
, state.num_queued_queries queued
, state.num_executing_queries executing
, state.num_executed_queries executed
from
STV_WLM_CLASSIFICATION_CONFIG class,
STV_WLM_SERVICE_CLASS_CONFIG config,
STV_WLM_SERVICE_CLASS_STATE state
where
class.action_service_class = config.service_class
and class.action_service_class = state.service_class
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/tutorial-wlm-understanding-default-processing.md
|
9a576043bb07-1
|
where
class.action_service_class = config.service_class
and class.action_service_class = state.service_class
and config.service_class > 4
order by config.service_class;
```
1. Run the following query to see the information that the view contains\.
```
select * from wlm_queue_state_vw;
```
The following is an example result\.
![\[Image NOT FOUND\]](http://docs.aws.amazon.com/redshift/latest/dg/images/psql_tutorial_wlm_010.png)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/tutorial-wlm-understanding-default-processing.md
|
52fd78e446bc-0
|
In this step, you create a view called WLM\_QUERY\_STATE\_VW\. This view returns information from the [STV\_WLM\_QUERY\_STATE](r_STV_WLM_QUERY_STATE.md) system table\.
You use this view throughout the tutorial to monitor the queries that are running\. The following table describes the data that the WLM\_QUERY\_STATE\_VW view returns\.
[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/redshift/latest/dg/tutorial-wlm-understanding-default-processing.html)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/tutorial-wlm-understanding-default-processing.md
|
e77b057b85e9-0
|
1. In psql, run the following query to create the WLM\_QUERY\_STATE\_VW view\.
```
create view WLM_QUERY_STATE_VW as
select query, (service_class-5) as queue, slot_count, trim(wlm_start_time) as start_time, trim(state) as state, trim(queue_time) as queue_time, trim(exec_time) as exec_time
from stv_wlm_query_state;
```
1. Run the following query to see the information that the view contains\.
```
select * from wlm_query_state_vw;
```
The following is an example result\.
![\[Image NOT FOUND\]](http://docs.aws.amazon.com/redshift/latest/dg/images/psql_tutorial_wlm_020.png)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/tutorial-wlm-understanding-default-processing.md
|
1bd8b4daa8ee-0
|
In this step, you run queries from multiple connections in psql and review the system tables to determine how the queries were routed for processing\.
For this step, you need two psql windows open:
+ In psql window 1, you run queries that monitor the state of the queues and queries using the views you already created in this tutorial\.
+ In psql window 2, you run long\-running queries to change the results you find in psql window 1\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/tutorial-wlm-understanding-default-processing.md
|
a06775fc4e3c-0
|
1. Open two psql windows\. If you already have one window open, you only need to open a second window\. You can use the same user account for both of these connections\.
1. In psql window 1, run the following query\.
```
select * from wlm_query_state_vw;
```
The following is an example result\.
![\[Image NOT FOUND\]](http://docs.aws.amazon.com/redshift/latest/dg/images/psql_tutorial_wlm_030.png)
This query returns a self\-referential result\. The query that is currently executing is the SELECT statement from this view\. A query on this view always returns at least one result\. Compare this result with the result that occurs after starting the long\-running query in the next step\.
1. In psql window 2, run a query from the TICKIT sample database\. This query should run for approximately a minute so that you have time to explore the results of the WLM\_QUEUE\_STATE\_VW view and the WLM\_QUERY\_STATE\_VW view that you created earlier\. In some cases, you might find that the query doesn't run long enough for you to query both views\. In these cases, you can increase the value of the filter on `l.listid `to make it run longer\.
**Note**
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/tutorial-wlm-understanding-default-processing.md
|
a06775fc4e3c-1
|
**Note**
To reduce query execution time and improve system performance, Amazon Redshift caches the results of certain types of queries in memory on the leader node\. When result caching is enabled, subsequent queries run much faster\. To prevent the query from running to quickly, disable result caching for the current session\.
To disable result caching for the current session, set the [enable\_result\_cache\_for\_session](r_enable_result_cache_for_session.md) parameter to `off`, as shown following\.
```
set enable_result_cache_for_session to off;
```
In psql window 2, run the following query\.
```
select avg(l.priceperticket*s.qtysold) from listing l, sales s where l.listid < 100000;
```
1. In psql window 1, query WLM\_QUEUE\_STATE\_VW and WLM\_QUERY\_STATE\_VW and compare the results to your earlier results\.
```
select * from wlm_queue_state_vw;
select * from wlm_query_state_vw;
```
The following are example results\.
![\[Image NOT FOUND\]](http://docs.aws.amazon.com/redshift/latest/dg/images/psql_tutorial_wlm_040.png)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/tutorial-wlm-understanding-default-processing.md
|
a06775fc4e3c-2
|
![\[Image NOT FOUND\]](http://docs.aws.amazon.com/redshift/latest/dg/images/psql_tutorial_wlm_050.png)
Note the following differences between your previous queries and the results in this step:
+ There are two rows now in WLM\_QUERY\_STATE\_VW\. One result is the self\-referential query for running a SELECT operation on this view\. The second result is the long\-running query from the previous step\.
+ The executing column in WLM\_QUEUE\_STATE\_VW has increased from 1 to 2\. This column entry means that there are two queries running in the queue\.
+ The executed column is incremented each time you run a query in the queue\.
The WLM\_QUEUE\_STATE\_VW view is useful for getting an overall view of the queues and how many queries are being processed in each queue\. The WLM\_QUERY\_STATE\_VW view is useful for getting a more detailed view of the individual queries that are currently running\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/tutorial-wlm-understanding-default-processing.md
|
15787e7d3f07-0
|
Amazon Redshift integrates with other AWS services to enable you to move, transform, and load your data quickly and reliably, using data security features\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/using-redshift-with-other-services.md
|
275c86845cae-0
|
Amazon Simple Storage Service \(Amazon S3\) is a web service that stores data in the cloud\. Amazon Redshift leverages parallel processing to read and load data from multiple data files stored in Amazon S3 buckets\. For more information, see [Loading data from Amazon S3](t_Loading-data-from-S3.md)\.
You can also use parallel processing to export data from your Amazon Redshift data warehouse to multiple data files on Amazon S3\. For more information, see [Unloading data](c_unloading_data.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/using-redshift-with-other-services.md
|
b6b751f916f0-0
|
Amazon DynamoDB is a fully managed NoSQL database service\. You can use the COPY command to load an Amazon Redshift table with data from a single Amazon DynamoDB table\. For more information, see [Loading data from an Amazon DynamoDB table](t_Loading-data-from-dynamodb.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/using-redshift-with-other-services.md
|
5f4b4ba6f412-0
|
You can use the COPY command in Amazon Redshift to load data from one or more remote hosts, such as Amazon EMR clusters, Amazon EC2 instances, or other computers\. COPY connects to the remote hosts using SSH and executes commands on the remote hosts to generate data\. Amazon Redshift supports multiple simultaneous connections\. The COPY command reads and loads the output from multiple host sources in parallel\. For more information, see [Loading data from remote
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/using-redshift-with-other-services.md
|
5f4b4ba6f412-1
|
For more information, see [Loading data from remote hosts](loading-data-from-remote-hosts.md)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/using-redshift-with-other-services.md
|
df29e83903fc-0
|
You can use AWS Data Pipeline to automate data movement and transformation into and out of Amazon Redshift\. By using the built\-in scheduling capabilities of AWS Data Pipeline, you can schedule and execute recurring jobs without having to write your own complex data transfer or transformation logic\. For example, you can set up a recurring job to automatically copy data from Amazon DynamoDB into Amazon Redshift\. For a tutorial that walks you through the process of
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/using-redshift-with-other-services.md
|
df29e83903fc-1
|
tutorial that walks you through the process of creating a pipeline that periodically moves data from Amazon S3 to Amazon Redshift, see [Copy data to Amazon Redshift using AWS Data Pipeline](https://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-copydata-redshift.html) in the AWS Data Pipeline Developer Guide\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/using-redshift-with-other-services.md
|
436a43f836cb-0
|
You can migrate data to Amazon Redshift using AWS Database Migration Service\. AWS DMS can migrate your data to and from most widely used commercial and open\-source databases such as Oracle, PostgreSQL, Microsoft SQL Server, Amazon Redshift, Aurora, DynamoDB, Amazon S3, MariaDB, and MySQL\. For more information, see [Using an Amazon Redshift database as a target for AWS Database Migration Service](https://docs.aws.amazon.com/dms/latest/userguide/CHAP_Target.Redshift.html)\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/using-redshift-with-other-services.md
|
41d5281a0a9b-0
|
You can efficiently add new data to an existing table by using a combination of updates and inserts from a staging table\. While Amazon Redshift does not support a single *merge*, or *upsert*, command to update a table from a single data source, you can perform a merge operation by creating a staging table and then using one of the methods described in this section to update the target table from the staging table\.
**Topics**
+ [Merge method 1: Replacing existing rows](#merge-method-replace-existing-rows)
+ [Merge method 2: Specifying a column list](#merge-method-specify-column-list)
+ [Creating a temporary staging table](merge-create-staging-table.md)
+ [Performing a merge operation by replacing existing rows](merge-replacing-existing-rows.md)
+ [Performing a merge operation by specifying a column list](merge-specify-a-column-list.md)
+ [Merge examples](merge-examples.md)
**Note**
You should run the entire merge operation, except for creating and dropping the temporary staging table, in a single transaction so that the transaction will roll back if any step fails\. Using a single transaction also reduces the number of commits, which saves time and resources\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/t_updating-inserting-using-staging-tables-.md
|
9e18923dee41-0
|
If you are overwriting all of the columns in the target table, the fastest method for performing a merge is by replacing the existing rows because it scans the target table only once, by using an inner join to delete rows that will be updated\. After the rows are deleted, they are replaced along with new rows by a single insert operation from the staging table\.
Use this method if all of the following are true:
+ Your target table and your staging table contain the same columns\.
+ You intend to replace all of the data in the target table columns with all of the staging table columns\.
+ You will use all of the rows in the staging table in the merge\.
If any of these criteria do not apply, use Merge Method 2: Specifying a column list, described in the following section\.
If you will not use all of the rows in the staging table, you can filter the DELETE and INSERT statements by using a WHERE clause to leave out rows that are not actually changing\. However, if most of the rows in the staging table will not participate in the merge, we recommend performing an UPDATE and an INSERT in separate steps, as described later in this section\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/t_updating-inserting-using-staging-tables-.md
|
80fe09c166c5-0
|
Use this method to update specific columns in the target table instead of overwriting entire rows\. This method takes longer than the previous method because it requires an extra update step\. Use this method if any of the following are true:
+ Not all of the columns in the target table are to be updated\.
+ Most rows in the staging table will not be used in the updates\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/t_updating-inserting-using-staging-tables-.md
|
633b1ce78108-0
|
Look at the query plan to find what steps have been pushed to the Amazon Redshift Spectrum layer\.
The following steps are related to the Redshift Spectrum query:
+ S3 Seq Scan
+ S3 HashAggregate
+ S3 Query Scan
+ Seq Scan PartitionInfo
+ Partition Loop
The following example shows the query plan for a query that joins an external table with a local table\. Note the S3 Seq Scan and S3 HashAggregate steps that were executed against the data on Amazon S3\.
```
explain
select top 10 spectrum.sales.eventid, sum(spectrum.sales.pricepaid)
from spectrum.sales, event
where spectrum.sales.eventid = event.eventid
and spectrum.sales.pricepaid > 30
group by spectrum.sales.eventid
order by 2 desc;
```
```
QUERY PLAN
-----------------------------------------------------------------------------
XN Limit (cost=1001055770628.63..1001055770628.65 rows=10 width=31)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/c-spectrum-external-performance.md
|
633b1ce78108-1
|
XN Limit (cost=1001055770628.63..1001055770628.65 rows=10 width=31)
-> XN Merge (cost=1001055770628.63..1001055770629.13 rows=200 width=31)
Merge Key: sum(sales.derived_col2)
-> XN Network (cost=1001055770628.63..1001055770629.13 rows=200 width=31)
Send to leader
-> XN Sort (cost=1001055770628.63..1001055770629.13 rows=200 width=31)
Sort Key: sum(sales.derived_col2)
-> XN HashAggregate (cost=1055770620.49..1055770620.99 rows=200 width=31)
-> XN Hash Join DS_BCAST_INNER (cost=3119.97..1055769620.49 rows=200000 width=31)
Hash Cond: ("outer".derived_col1 = "inner".eventid)
-> XN S3 Query Scan sales (cost=3010.00..5010.50 rows=200000 width=31)
-> S3 HashAggregate (cost=3010.00..3010.50 rows=200000 width=16)
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/c-spectrum-external-performance.md
|
633b1ce78108-2
|
-> S3 HashAggregate (cost=3010.00..3010.50 rows=200000 width=16)
-> S3 Seq Scan spectrum.sales location:"s3://awssampledbuswest2/tickit/spectrum/sales" format:TEXT (cost=0.00..2150.00 rows=172000 width=16)
Filter: (pricepaid > 30.00)
-> XN Hash (cost=87.98..87.98 rows=8798 width=4)
-> XN Seq Scan on event (cost=0.00..87.98 rows=8798 width=4)
```
Note the following elements in the query plan:
+ The `S3 Seq Scan` node shows the filter `pricepaid > 30.00` was processed in the Redshift Spectrum layer\.
A filter node under the `XN S3 Query Scan` node indicates predicate processing in Amazon Redshift on top of the data returned from the Redshift Spectrum layer\.
+ The `S3 HashAggregate` node indicates aggregation in the Redshift Spectrum layer for the group by clause \(`group by spectrum.sales.eventid`\)\.
Following are ways to improve Redshift Spectrum performance:
+ Use Apache Parquet formatted data files\. Parquet stores data in a columnar format, so Redshift Spectrum can eliminate unneeded columns from the scan\. When data is in text\-file format, Redshift Spectrum needs to scan the entire file\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/c-spectrum-external-performance.md
|
633b1ce78108-3
|
+ Use the fewest columns possible in your queries\.
+ Use multiple files to optimize for parallel processing\. Keep your file sizes larger than 64 MB\. Avoid data size skew by keeping files about the same size\.
+ Put your large fact tables in Amazon S3 and keep your frequently used, smaller dimension tables in your local Amazon Redshift database\.
+ Update external table statistics by setting the TABLE PROPERTIES numRows parameter\. Use [CREATE EXTERNAL TABLE](r_CREATE_EXTERNAL_TABLE.md) or [ALTER TABLE](r_ALTER_TABLE.md) to set the TABLE PROPERTIES numRows parameter to reflect the number of rows in the table\. Amazon Redshift doesn't analyze external tables to generate the table statistics that the query optimizer uses to generate a query plan\. If table statistics aren't set for an external table, Amazon Redshift generates a query execution plan\. Amazon Redshift generates this plan based on the assumption that external tables are the larger tables and local tables are the smaller tables\.
+ The Amazon Redshift query planner pushes predicates and aggregations to the Redshift Spectrum query layer whenever possible\. When large amounts of data are returned from Amazon S3, the processing is limited by your cluster's resources\. Redshift Spectrum scales automatically to process large requests\. Thus, your overall performance improves whenever you can push processing to the Redshift Spectrum layer\.
+ Write your queries to use filters and aggregations that are eligible to be pushed to the Redshift Spectrum layer\.
The following are examples of some operations that can be pushed to the Redshift Spectrum layer:
+ GROUP BY clauses
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/c-spectrum-external-performance.md
|
633b1ce78108-4
|
The following are examples of some operations that can be pushed to the Redshift Spectrum layer:
+ GROUP BY clauses
+ Comparison conditions and pattern\-matching conditions, such as LIKE\.
+ Aggregate functions, such as COUNT, SUM, AVG, MIN, and MAX\.
+ String functions\.
Operations that can't be pushed to the Redshift Spectrum layer include DISTINCT and ORDER BY\.
+ Use partitions to limit the data that is scanned\. Partition your data based on your most common query predicates, then prune partitions by filtering on partition columns\. For more information, see [Partitioning Redshift Spectrum external tables](c-spectrum-external-tables.md#c-spectrum-external-tables-partitioning)\.
Query [SVL\_S3PARTITION](r_SVL_S3PARTITION.md) to view total partitions and qualified partitions\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/c-spectrum-external-performance.md
|
49f8d929c339-0
|
You can monitor Amazon Redshift Spectrum queries using the following system views:
+ [SVL\_S3QUERY](r_SVL_S3QUERY.md)
Use the SVL\_S3QUERY view to get details about Redshift Spectrum queries \(S3 queries\) at the segment and node slice level\.
+ [SVL\_S3QUERY\_SUMMARY](r_SVL_S3QUERY_SUMMARY.md)
Use the SVL\_S3QUERY\_SUMMARY view to get a summary of all Amazon Redshift Spectrum queries \(S3 queries\) that have been run on the system\.
The following are some things to look for in SVL\_S3QUERY\_SUMMARY:
+ The number of files that were processed by the Redshift Spectrum query\.
+ The number of bytes scanned from Amazon S3\. The cost of a Redshift Spectrum query is reflected in the amount of data scanned from Amazon S3\.
+ The number of bytes returned from the Redshift Spectrum layer to the cluster\. A large amount of data returned might affect system performance\.
+ The maximum duration and average duration of Redshift Spectrum requests\. Long\-running requests might indicate a bottleneck\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/c-spectrum-metrics.md
|
2eff4419d139-0
|
ST\_AsEWKT returns the extended well\-known text \(EWKT\) representation of an input geometry\.
|
https://github.com/siagholami/aws-documentation/tree/main/documents/amazon-redshift-developer-guide/doc_source/ST_AsEWKT-function.md
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.