本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
Aurora PostgreSQL Limitless Database 的 DML 限制和其他資訊
下列主題說明限制,或提供 Aurora PostgreSQL Limitless Database 中 DML 和查詢處理 SQL 命令的詳細資訊。
ANALYZE
ANALYZE 命令會收集資料庫中資料表內容的統計資料。之後,查詢規劃器會使用這些統計資料,來協助判斷最有效率的查詢執行計劃。如需詳細資訊,請參閱 PostgreSQL 說明文件中的 ANALYZE
在 Aurora PostgreSQL Limitless Database 中,ANALYZE 命令會在執行時收集所有路由器和碎片中的資料表統計資料。
為了防止在 ANALYZE 執行期間計算每個路由器的統計資料,系統會在其中一個路由器計算資料表統計資料,然後複製到對等路由器。
CLUSTER
CLUSTER 命令會根據索引實際重新排序資料表。必須已在資料表上定義索引。在 Aurora PostgreSQL Limitless Database 中,叢集僅對於存在於每個碎片的索引部分有效。
如需詳細資訊,請參閱 PostgreSQL 文件中的 CLUSTER
EXPLAIN
您可以使用下列參數,來設定來自 EXPLAIN 命令的輸出:
-
rds_aurora.limitless_explain_options:EXPLAIN輸出中要包含的內容。預設值為single_shard_optimization:會顯示計劃是否為單一碎片最佳化,但不包含碎片計劃。
在此範例中,EXPLAIN 輸出不會顯示碎片中的計劃。
postgres_limitless=> EXPLAIN SELECT * FROM employees where id =25; QUERY PLAN ------------------------------------------------------ Foreign Scan (cost=100.00..101.00 rows=100 width=0) Single Shard Optimized (2 rows)
現在,我們將 rds_aurora.limitless_explain_options 設定為包含 shard_plans 和 single_shard_optimization。我們可以檢視路由器和碎片上陳述式的執行計劃。此外,我們會停用 enable_seqscan 參數,強制在碎片層使用索引掃描。
postgres_limitless=> SET rds_aurora.limitless_explain_options = shard_plans, single_shard_optimization; SET postgres_limitless=> SET enable_seqscan = OFF; SET postgres_limitless=> EXPLAIN SELECT * FROM employees WHERE id = 25; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------- Foreign Scan (cost=100.00..101.00 rows=100 width=0) Remote Plans from Shard postgres_s4: Index Scan using employees_ts00287_id_idx on employees_ts00287 employees_fs00003 (cost=0.14..8.16 rows=1 width=15) Index Cond: (id = 25) Single Shard Optimized (5 rows)
如需 EXPLAIN 命令的詳細資訊,請參閱 PostgreSQL 文件中的 EXPLAIN
INSERT
Aurora PostgreSQL Limitless Database 中支援大多數 INSERT 命令。
PostgreSQL 沒有明確的 UPSERT 命令,但支援 INSERT ... ON CONFLICT 陳述式。
如果衝突動作具有子查詢或可變函數,則不支援 INSERT ... ON CONFLICT:
-- RANDOM is a mutable function. INSERT INTO sharded_table VALUES (1, 100) ON CONFLICT (id) DO UPDATE SET other_id = RANDOM(); ERROR: Aurora Limitless Tables doesn't support pushdown-unsafe functions with DO UPDATE clauses.
如需 INSERT 命令的詳細資訊,請參閱 PostgreSQL 文件中的 INSERT
UPDATE
不支援更新碎片索引鍵。例如,您有一個名為 customers 的碎片資料表 (內含碎片索引鍵 customer_id)。下列 DML 陳述式會導致錯誤:
postgres_limitless=> UPDATE customers SET customer_id = 11 WHERE customer_id =1; ERROR: Shard key column update is not supported postgres_limitless=> UPDATE customers SET customer_id = 11 WHERE customer_name='abc'; ERROR: Shard key column update is not supported
若要更新碎片索引鍵,首先您必須 DELETE 具有碎片索引鍵的列,然後 INSERT 具有更新碎片索引鍵值的新列。
如需 UPDATE 命令的詳細資訊,請參閱 PostgreSQL 文件中的更新資料
VACUUM
您可以在碎片和參考資料表執行清空。Aurora PostgreSQL Limitless Database 中完全支援下列 VACUUM 函數:
-
VACUUM
-
DISABLE_PAGE_SKIPPING
-
FREEZE
-
FULL
-
INDEX_CLEANUP
-
PARALLEL
-
PROCESS_TOAST
-
TRUNCATE
-
詳細
Aurora PostgreSQL Limitless Database 上的 VACUUM 具有下列限制:
-
不支援 pg_visibility_map
延伸模組。 -
不支援使用 pg_stat_all_indexes
檢視檢查未使用的索引。 -
未實作 pg_stat_user_indexes
、pg_class 和 pg_stats 的合併檢視。
如需 VACUUM 命令的詳細資訊,請參閱 PostgreSQL 文件中的 VACUUM