Arrays in Postgresql Processes

From: "Aspire Something" <aspire420(at)hotpop(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Arrays in Postgresql Processes
Date: 2003-03-01 12:33:51
Message-ID: 004801c2dfee$dc4dc550$c9c832c0@societykotla
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi all ,

In our project we have to run a plpgsql function
its. algorithm is something like this
1. Determine the id (we will call it roll_number) valid for the process from
the huge table,
Roll number is a Seqence index with value starting from 1
....... BIGINT
2. When the roll_number is valid selects its data from some other huge table
.
3 Now run a plpgsql function on the Roll number.

To do this I am using a code like this
<code>
create function blah blah Returns XXX as '
all var declared;
roll_data school_data%ROWTYPE;
BEGIN
select max(maxl_roll) from school_data ;
FOR i IN 1..max_roll LOOP
select * from school_data where roll_number = i ;
if roll_data.class = 10 THEN
do some work
END IF;
END LOOP;
END;
some more blahblah plpgsql '
</code>
Now my question is =>
1. Is this approch execute code fast when u are selecting roll_number 1 thru
10Thusand + .
2. Can we use array for the above thing as
a. Make an array of the valid roll_numbers. such as
('IDX'=>'ROLL_NUMBER'........)
b. Now select the array element by the index which will produce the
roll_number and work on it.
c. Array could be build by for loop
3. Will the array approch execute code fast. if yes can you please give me
some refrences so that i can actually
build one such function.
4. Lastly if i use views will they help in fas execution

Please pour in your valuable knowledge

Regards,
V Kashyap.

Browse pgsql-sql by date

  From Date Subject
Next Message Oliver Elphick 2003-03-01 13:02:01 Re: Users and groups
Previous Message Victor Yegorov 2003-03-01 08:41:26 Re: Beginner needs help