rules - optimizing

From: Marcin Grondecki <ojciec(at)mtl(dot)pl>
To: pgsql-general(at)postgresql(dot)org
Subject: rules - optimizing
Date: 1998-12-16 16:04:47
Views: Raw Message | Whole Thread | Download mbox
Lists: pgsql-general

Hi ppl
I've started to use rules. Something strange with one of them:
AIX 4.1
PostgreSQL 6.4

create word_list (id int4, word char(15), count int4 default 0);
create unique index word_list_word_uidx on word_list (word);
(something inserted into word_list)

create table temp (word char(15));
create rule ins_word as on insert to temp do instead update word_list set
count=count+1 where word=new.word;

I'd like to use "temp" relation as some kind of filter; now i could f.e.
import big chunk of
data from text file (import word) with simple "copy", and this should count
words in file
storing results in word_list.count.
And it works, but...

explain update word_list set count=count+1 where word='aix';
shows index scan (using word_list_word_uidx of course)

explain insert into temp (word) values ('aix');
gives seq scan as result.

Relation word_list has about 300 000 tuples, so it's rather boring to w8 1
or 2 s to insert ONE word.

Could i do smth to enforce index scan when using above rule?
BTW. sorry for my english :(

Marcin Grondecki

***** I'm not a complete idiot, some parts are missing...

Browse pgsql-general by date

  From Date Subject
Next Message Albert Chen 1998-12-17 01:03:52 Why PostgreSQL is better than other commerial softwares?
Previous Message Oleg Broytmann 1998-12-16 08:55:46 Re: [GENERAL] Date & Datetime problems