我有以下 postgresql 表:
CREATE TABLE "initialTable" (
"paramIDFKey" integer,
"featAIDFKey" integer,
"featBIDFKey" integer,
"featAPresent" boolean,
"featBPresent" boolean,
"dataID" text
);
我通过以下命令更新此表:
UPDATE "initalTable"
SET "dataID" = "dataID" || '#' || 'NEWDATA'
where
"paramIDFKey" = parameterID
and "featAIDFKey" = featAIDFKey
and "featBIDFKey" = featBIDFKey
and "featAPresent" = featAPresent
and "featBPresent" = featBPresent
如您所见,我正在更新每一行的 dataID。此更新用作附加。它将新数据附加到以前的数据中。
这太慢了。特别是当“dataID”列变大时。
以下是“解释”结果:
"Bitmap Heap Scan on "initialTable" (cost=4.27..8.29 rows=1 width=974)"
" Recheck Cond: (("paramIDFKey" = 53) AND ("featAIDFKey" = 0) AND ("featBIDFKey" = 95))"
" Filter: ("featAPresent" AND (NOT "featBPresent"))"
" -> Bitmap Index Scan on "InexactIndex" (cost=0.00..4.27 rows=1 width=0)"
" Index Cond: (("paramIDFKey" = 53) AND ("featAIDFKey" = 0) AND ("featBIDFKey" = 95) AND ("featAPresent" = true) AND ("featBPresent" = false))"
解释分析:
"Bitmap Heap Scan on "Inexact2Comb" (cost=4.27..8.29 rows=1 width=974) (actual time=0.621..0.675 rows=1 loops=1)"
" Recheck Cond: (("paramIDFKey" = 53) AND ("featAIDFKey" = 0) AND ("featBIDFKey" = 95))"
" Filter: ("featAPresent" AND (NOT "featBPresent"))"
" -> Bitmap Index Scan on "InexactIndex" (cost=0.00..4.27 rows=1 width=0) (actual time=0.026..0.026 rows=1 loops=1)"
" Index Cond: (("paramIDFKey" = 53) AND ("featAIDFKey" = 0) AND ("featBIDFKey" = 95) AND ("featAPresent" = true) AND ("featBPresent" = false))"
"Total runtime: 13.780 ms"
和版本:
"PostgreSQL 8.4.14, compiled by Visual C++ build 1400, 32-bit"
有什么建议吗?