Skip site navigation (1) Skip section navigation (2)

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
Message-ID: (view raw, whole thread or download thread 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...

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group