split コマンドでファイルを分割したメモ。
$ split -d -a 3 -l 1000 base_insert.cql ks_insert_ $ ls |head base_insert.cql ks_insert_000 ks_insert_001 ks_insert_002 ks_insert_003 ks_insert_004 ks_insert_005 ks_insert_006 ks_insert_007
split コマンドでファイルを分割したメモ。
$ split -d -a 3 -l 1000 base_insert.cql ks_insert_ $ ls |head base_insert.cql ks_insert_000 ks_insert_001 ks_insert_002 ks_insert_003 ks_insert_004 ks_insert_005 ks_insert_006 ks_insert_007
$ cat insert_small.cql CONSISTENCY LOCAL_QUORUM ; INSERT INTO poc.partition_id_dist_test (partition_id, date_time) VALUES (001, '2024-01-10 17:30:00'); INSERT INTO poc.partition_id_dist_test (partition_id, date_time) VALUES (002, '2024-01-10 17:30:00'); INSERT INTO poc.partition_id_dist_test (partition_id, date_time) VALUES (003, '2024-01-10 17:30:00'); INSERT INTO poc.partition_id_dist_test (partition_id, date_time) VALUES (004, '2024-01-10 17:30:00'); INSERT INTO poc.partition_id_dist_test (partition_id, date_time) VALUES (005, '2024-01-10 17:30:00'); INSERT INTO poc.partition_id_dist_test (partition_id, date_time) VALUES (006, '2024-01-10 17:30:00'); INSERT INTO poc.partition_id_dist_test (partition_id, date_time) VALUES (007, '2024-01-10 17:30:00'); INSERT INTO poc.partition_id_dist_test (partition_id, date_time) VALUES (008, '2024-01-10 17:30:00'); INSERT INTO poc.partition_id_dist_test (partition_id, date_time) VALUES (009, '2024-01-10 17:30:00'); INSERT INTO poc.partition_id_dist_test (partition_id, date_time) VALUES (010, '2024-01-10 17:30:00');
$ cqlsh cassandra.ap-northeast-1.amazonaws.com 9142 --ssl -f insert_small.cql Consistency level set to LOCAL_QUORUM.
Amazon Keyspaces で VPC エンドポイントを設定しているVPCでグローバルエンドポイントとVPCエンドポイントを併用する方法。
[ec2-user@ip-172-31-17-86 ~]$ cqlsh cassandra.ap-northeast-1.amazonaws.com 9142 --ssl Connected to Amazon Keyspaces at cassandra.ap-northeast-1.amazonaws.com:9142 [cqlsh 6.1.0 | Cassandra 3.11.2 | CQL spec 3.4.4 | Native protocol v4] Use HELP for help. cqlsh> select * from system.peers; peer | data_center | host_id | preferred_ip | rack | release_version | rpc_address | schema_version | tokens ----------------+----------------+--------------------------------------+----------------+----------------+-----------------+----------------+--------------------------------------+-------------------------- 18.177.156.232 | ap-northeast-1 | 0984ca2e-8ee7-397b-88a0-7d8783efd305 | 18.177.156.232 | ap-northeast-1 | 3.11.2 | 18.177.156.232 | 05deae2d-6405-494d-a965-c0e5836bcb3c | {'-7173733806442603407'} 18.177.156.237 | ap-northeast-1 | 7afb0ca0-cfef-3ab4-a9d8-8919c468a586 | 18.177.156.237 | ap-northeast-1 | 3.11.2 | 18.177.156.237 | 05deae2d-6405-494d-a965-c0e5836bcb3c | {'-5124095576030431006'} 18.177.156.207 | ap-northeast-1 | 4aed79fb-8933-388a-8db1-df800c635b8c | 18.177.156.207 | ap-northeast-1 | 3.11.2 | 18.177.156.207 | 05deae2d-6405-494d-a965-c0e5836bcb3c | {'-3074457345618258605'} 18.177.156.213 | ap-northeast-1 | 01290fa4-e20f-3fb4-ace4-7406d48c52b3 | 18.177.156.213 | ap-northeast-1 | 3.11.2 | 18.177.156.213 | 05deae2d-6405-494d-a965-c0e5836bcb3c | {'-1024819115206086204'} 18.177.156.231 | ap-northeast-1 | 33d42b23-cc2c-3460-9646-b4bffedf646f | 18.177.156.231 | ap-northeast-1 | 3.11.2 | 18.177.156.231 | 05deae2d-6405-494d-a965-c0e5836bcb3c | {'1024819115206086197'} 18.177.156.253 | ap-northeast-1 | def25f13-8435-31b6-b250-c900fe4785aa | 18.177.156.253 | ap-northeast-1 | 3.11.2 | 18.177.156.253 | 05deae2d-6405-494d-a965-c0e5836bcb3c | {'3074457345618258598'} 18.177.156.214 | ap-northeast-1 | 49074ce2-2f74-36bd-8ed4-54568cc53079 | 18.177.156.214 | ap-northeast-1 | 3.11.2 | 18.177.156.214 | 05deae2d-6405-494d-a965-c0e5836bcb3c | {'5124095576030430999'} 18.177.156.212 | ap-northeast-1 | 7dacf8a2-b751-3494-9062-327c622e645c | 18.177.156.212 | ap-northeast-1 | 3.11.2 | 18.177.156.212 | 05deae2d-6405-494d-a965-c0e5836bcb3c | {'7173733806442603400'} 18.177.156.192 | ap-northeast-1 | 973a0ad2-4c73-360e-9928-732d864bced6 | 18.177.156.192 | ap-northeast-1 | 3.11.2 | 18.177.156.192 | 05deae2d-6405-494d-a965-c0e5836bcb3c | {'9223372036854775801'} (9 rows)
[ec2-user@ip-172-31-17-86 ~]$ cqlsh vpce-0f5f82f2f4d135942-2um9xrp5.cassandra.ap-northeast-1.vpce.amazonaws.com 9142 --ssl Connected to Amazon Keyspaces at vpce-0f5f82f2f4d135942-2um9xrp5.cassandra.ap-northeast-1.vpce.amazonaws.com:9142 [cqlsh 6.1.0 | Cassandra 3.11.2 | CQL spec 3.4.4 | Native protocol v4] Use HELP for help. cqlsh> select * from system.peers; peer | data_center | host_id | preferred_ip | rack | release_version | rpc_address | schema_version | tokens ---------------+----------------+--------------------------------------+---------------+----------------+-----------------+---------------+--------------------------------------+-------------------------- 172.31.46.196 | ap-northeast-1 | 90ab788e-055a-3799-a5e6-1c682d38e7ab | 172.31.46.196 | ap-northeast-1 | 3.11.2 | 172.31.46.196 | 05deae2d-6405-494d-a965-c0e5836bcb3c | {'-3074457345618258603'} 172.31.30.103 | ap-northeast-1 | 76a77963-9462-30e7-89f2-dbb975ec5fbf | 172.31.30.103 | ap-northeast-1 | 3.11.2 | 172.31.30.103 | 05deae2d-6405-494d-a965-c0e5836bcb3c | {'3074457345618258602'} 172.31.3.159 | ap-northeast-1 | caaf4736-f9c8-3eb5-8c7d-aada28a89452 | 172.31.3.159 | ap-northeast-1 | 3.11.2 | 172.31.3.159 | 05deae2d-6405-494d-a965-c0e5836bcb3c | {'9223372036854775807'} (3 rows) cqlsh>
STL_QUERYTEXT に保存された SQL を再構築するには、次の SQL を実行します。
select LISTAGG(CASE WHEN LEN(RTRIM(text)) = 0 THEN text ELSE RTRIM(text) END, '') within group (order by sequence) AS text from stl_querytext where query=pg_last_query_id();STL_QUERYTEXT - Amazon Redshift
select text from STL_QUERYTEXT where query = 'クエリID' order by sequenceよく使うRedshift運用系SQL #AWS - Qiita
Read operations such as GetItem, Query, and Scan provide an optional ConsistentRead parameter. If you set ConsistentRead to true, DynamoDB returns a response with the most up-to-date data, reflecting the updates from all prior write operations that were successful.
Read consistency - Amazon DynamoDB
ConsistentReadオプション(読み取り一貫性)とはこのような読み取りによる差がないことを保証するもので、スキャン時にこのオプションをつけることでスキャン前に登録、変更された値は確実に読み取る事ができます。具体的には書き込まれている3箇所より2箇所の値を読み取り、一致すればその値を、一致しなければもう1箇所の値を読んで2箇所に書き込まれている値を返す、という仕組みになります。
DynamoDBの整合性モデル #DynamoDB - Qiita
DynamoDB does not require tight clock synchronization, and unlike Spanner does not assume any uncertainty window. It does not need MVCC and avoids any locking scheme (e.g. 2PL or deterministic locking). The timestamp ordering approach used by DynamoDB is very simple: assign timestamps to transactions and let these timestamps define the serialization order, i.e., a transaction with a smaller timestamp must appear to be executed before the one with a larger timestamp.
Amazon DynamoDB: ACID Transactions using Timestamp Ordering
トランザクション競合は、トランザクション内の項目に対する項目レベルの同時リクエスト中に発生する場合があります。トランザクション競合は、次のシナリオで発生する場合があります。
Amazon DynamoDB Transactions: 仕組み - Amazon DynamoDB
- 項目に対する PutItem、UpdateItem、または DeleteItem リクエストが、同じ項目を含む継続中の TransactWriteItems リクエストと競合する。
- TransactWriteItems リクエスト内の項目が、継続中の別の TransactWriteItems リクエストの一部である。
- TransactGetItems リクエスト内の項目が、継続中の TransactWriteItems、BatchWriteItem、PutItem、UpdateItem、または DeleteItem リクエストの一部である。
Redshift Serveless でモニタリングする項目
$ psql -a "host=redshift-cluster-poc-central.********.ap-northeast-1.redshift.amazonaws.com user=awsuser dbname=dev port=5439" psql (13.7, server 8.0.2) SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) Type "help" for help. dev=# \i case_sensitive_test.sql -- enable_case_sensitive_identifier = false show enable_case_sensitive_identifier; enable_case_sensitive_identifier ---------------------------------- off (1 row) create table "TEST_UC" ("ID" INT); CREATE TABLE create table "test_lc" ("id" int); CREATE TABLE select id from test_uc; id ---- (0 rows) select ID from TEST_UC; id ---- (0 rows) select "ID" from "TEST_UC"; id ---- (0 rows) select id from test_lc; id ---- (0 rows) select ID from TEST_LC; id ---- (0 rows) select "ID" from "TEST_LC"; id ---- (0 rows) drop table test_uc; DROP TABLE drop table test_lc; DROP TABLE -- enable_case_sensitive_identifier = true set enable_case_sensitive_identifier to true; SET show enable_case_sensitive_identifier; enable_case_sensitive_identifier ---------------------------------- on (1 row) create table "TEST_UC" ("ID" INT); CREATE TABLE create table "test_lc" ("id" int); CREATE TABLE select id from test_uc; psql:case_sensitive_test.sql:25: ERROR: relation "test_uc" does not exist select ID from TEST_UC; psql:case_sensitive_test.sql:26: ERROR: relation "test_uc" does not exist select "ID" from "TEST_UC"; ID ---- (0 rows) select id from test_lc; id ---- (0 rows) select ID from TEST_LC; id ---- (0 rows) select "ID" from "TEST_LC"; psql:case_sensitive_test.sql:31: ERROR: relation "TEST_LC" does not exist drop table "TEST_UC"; DROP TABLE drop table "test_lc"; DROP TABLE dev=#