[pgsql-jp: 31972] countが以上に遅い。
小野昇一
ono @ searchina.ne.jp
2004年 1月 13日 (火) 12:55:47 JST
はじめまして、小野です。
環境
OS:RedHat7.3
PostgreSQL:7.2.3
現在ニュースデータを検索するシステムを運用しています。
たいしたものではなく、年間7000くらいのニュースがありまして、
それを日々蓄積し、検索させる。といったものです。
下記テーブル設計です。
-- news_table ---
uniqid | integer | not null default nextval('"news_table_uniqid_seq"'::text)
filename | text | not null
filedir | text | not null
subject | text | not null
message | text | not null
img | text | not null
category | smallint | not null
date | timestamp without time zone | not null
flg | smallint | not null default '1'
現状全データで、2万ほどで、本文を丸ごと入れています。
(本文は一般的なニュースと同じくらい)
で、こまったことに、本文からの検索、たとえば、
select uniqid from news_table where message like '%日本%' and flg=1
offset 0 limit 10;
で検索すると早く出るのですが、
select count(*) from news_table where message like '%日本%' and flg=1;
と検索すると、20秒くらい掛かってしまいます。
どうにかconntが早く帰ってくる方法が無いか思案していますが、
messageには、大量のデータが入っているので、indexもはれません。
(というか、はってもいみない)
ご教示お願いいたします。
━━━……‥ ・ ・ ・ ・ ・Searchina Co., Ltd.
株式会社サーチナ
アプリケーション事業部 マネージャー
小野 昇一 ono @ searchina.ne.jp
中国情報局 http://searchina.ne.jp/
中国株速報 http://stock.searchina.ne.jp/
中国調査ならお任せ! http://marketing.searchina.net/
本社 〒161-0033 東京都新宿区下落合1-8-10
TEL:03-5348-6697(代表)
FAX:03-5348-6696
━━━━━━━━━━━━━━━━━━━━━
※中国経済産業新聞 『サーチナポスト』
年間購読4,800円 詳細は ⇒ http://searchina.ne.jp/post/
pgsql-jp メーリングリストの案内