0
遅いです:PostgreSQLでは、単純な私はテーブル持って
CREATE TABLE my_table
(
id integer NOT NULL DEFAULT nextval('seq_my_table_id'::regclass),
fk_id1 integer NOT NULL,
fk_id2 smallint NOT NULL,
name character varying(255) NOT NULL,
description text,
currency_name character varying(3) NOT NULL,
created timestamp with time zone NOT NULL DEFAULT now(),
updated timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT "PK_my_table_id" PRIMARY KEY (id),
CONSTRAINT "FK_my_table_fk_id1" FOREIGN KEY (fk_id1)
REFERENCES my_table2 (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED,
CONSTRAINT "FK_my_table_fk_id2" FOREIGN KEY (fk_id2)
REFERENCES my_table3 (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED
)
WITH (
OIDS=FALSE,
autovacuum_enabled=true,
autovacuum_vacuum_threshold=50,
autovacuum_vacuum_scale_factor=0.2,
autovacuum_analyze_threshold=50,
autovacuum_analyze_scale_factor=0.1,
autovacuum_vacuum_cost_delay=20,
autovacuum_vacuum_cost_limit=200,
autovacuum_freeze_min_age=50000000,
autovacuum_freeze_max_age=200000000,
autovacuum_freeze_table_age=150000000
);
ALTER TABLE my_table
OWNER TO postgres;
CREATE INDEX my_table_fk_id1
ON my_table
USING btree
(fk_id1);
CREATE INDEX my_table_fk_id2
ON my_table
USING btree
(fk_id2);
テーブルのレコードがカウントを
select count(id) from my_table; --24061
select count(id) from my_table2; --24061
select count(id) from my_table3; --123
select * from my_table -- ~17sec
vacuum/analyze
実行時間 - 効果なし
description
- 長〜4000各行の文字列
postgres.conf
- スタンダール設定
バージョン:9.1
は説明を除くすべてのフィールドを選択する説明を選択速度をicreaseする方法〜1,5秒
に実行時間を短縮?
UPD
--explain analyze select * from my_table
"Seq Scan on my_table (cost=0.00..3425.79 rows=24079 width=1015) (actual time=0.019..17.238 rows=24079 loops=1)"
"Total runtime: 18.649 ms"
'select *'文の結果を表示するアプリケーションはどれですか?どのランタイムが 'Explain analyze select * from my_table'と報告されたのですか? –
'select *'例だけですが、 'select fk_id1、fk_id2、name、currency_name、description' - (同じ17秒)を使用します。質問の更新も参照してください。 – cetver
ランタイム*サーバー上の**はわずか18 **ミリ秒(18.649ms)です。つまり、フロントエンドで17 *秒かかる場合、ネットワーク経由で(またはクライアントアプリケーション内で)ローを送信する時間が失われます。 –