💴

S3 Tableをとりあえず作る

に公開

やりたいこと

  • S3 Table をとりあえず作る

俯瞰図

https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-integrating-aws.html#how-table-integration-works

やり方

create-table-bucket

reference
Creates a table bucket.

  • cmd
aws s3tables create-table-bucket \
  --name shigeruoda-test-20250315
  • result
{
    "arn": "arn:aws:s3tables:ap-northeast-1:123456789012:bucket/shigeruoda-test-20250315"
}
  • console

create-namespace

reference
Creates a namespace. A namespace is a logical grouping of tables within your table bucket, which you can use to organize tables.

  • cmd
aws s3tables create-namespace \
  --table-bucket-arn arn:aws:s3tables:ap-northeast-1:123456789012:bucket/shigeruoda-test-20250315 \
  --namespace shigeruoda_namespace

table-bucket は Name でなくて ARN 指定か、また namespace に"-"や"."を使えないんだね
https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-namespace-create.html

  • result
{
    "tableBucketARN": "arn:aws:s3tables:ap-northeast-1:123456789012:bucket/shigeruoda-test-20250315",
    "namespace": [
        "shigeruoda_namespace"
    ]
}

create-table

reference
Creates a new table associated with the given namespace in a table bucket.
type のバリエーションはこちらを参照、v3 は利用はできないです。
俯瞰図では namespace がなくても table 作成できるように見えるけど、namespace が必須。

  • cmd
cat << EOF > create-table.json
{
    "tableBucketARN": "arn:aws:s3tables:ap-northeast-1:123456789012:bucket/shigeruoda-test-20250315",
    "namespace": "shigeruoda_namespace",
    "name": "shigeruoda_table1",
    "format": "ICEBERG",
    "metadata": {
        "iceberg": {
            "schema": {
                "fields": [
                  {"name": "string", "type": "string", "required": true},
                  {"name": "int", "type": "int", "required": false}
                ]
            }
        }
    }
}
EOF

aws s3tables create-table --cli-input-json file://create-table.json
rm create-table.json
  • result
{
    "tableARN": "arn:aws:s3tables:ap-northeast-1:123456789012:bucket/shigeruoda-test-20250315/table/1533529f-9c67-493a-b3fc-25b2315329a4",
    "versionToken": "659ce6e13b177a46221c"
}
  • console

Athena

Table を作成すると Athena の画面でも確認することができます

  • console

DML

  • Insert
INSERT INTO shigeruoda_table1 (string, int) VALUES ('string', 100);

キュー内の時間:95 ms, 実行時間:8.694 sec
とそれなりに時間がかかります。

  • Update
UPDATE shigeruoda_table1 SET int = 200 WHERE string = 'string';

キュー内の時間:92 ms, 実行時間:10.796 sec

  • Select
SELECT * FROM "shigeruoda_namespace"."shigeruoda_table1" limit 10;

  • Delete
DELETE FROM shigeruoda_table1 WHERE string = 'string';

キュー内の時間:108 ms, 実行時間:11.583 sec

Costについて

ストレージ料金

項目 S3標準 S3Table
モニタリング、全ストレージ/月 - USD 0.025/1,000 obj
最初の 50 TB/月 USD 0.025/GB USD 0.0288/GB
次の 450 TB/月 USD 0.024/GB USD 0.0276/GB
500 TB/月以上 USD 0.023/GB USD 0.0265/GB

リクエストの料金

項目 S3標準 S3Table
PUT、POST、LIST USD 0.0047/1,000 req USD 0.0047/1,000 req
GET、他 USD 0.00037/1,000 req USD 0.00037/1,000 req

メンテナンスの料金

項目 S3標準 S3Table
圧縮 - オブジェクト - USD 0.004/1,000 obj
圧縮 - データ処理量 - USD 0.05/GB

圧縮は小さいファイルをまとめることで性能を上げる物となります。
https://docs.aws.amazon.com/ja_jp/glue/latest/dg/compaction-management.html

Discussion