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: 3.0.6.32.19981216160447.007a6e10@mtl.pl (view raw or flat)
Thread:
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
create unique index word_list_word_uidx on word_list (word);
CREATE
...
(something inserted into word_list)

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

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)

but
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
ojciec(at)mtl(dot)pl

***** 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-2014 The PostgreSQL Global Development Group