X-Original-To: pgsql-sql@postgresql.org Received: from snickers.hotpop.com (snickers.hotpop.com [204.57.55.49]) by postgresql.org (Postfix) with ESMTP id EDD72475F39 for ; Thu, 6 Mar 2003 01:04:37 -0500 (EST) Received: from hotpop.com (kubrick.hotpop.com [204.57.55.16]) by snickers.hotpop.com (Postfix) with SMTP id 87110726A7 for ; Thu, 6 Mar 2003 05:58:08 +0000 (UTC) Received: from societykotla (unknown [61.0.95.121]) by smtp-2.hotpop.com (Postfix) with ESMTP id DE305180134 for ; Thu, 6 Mar 2003 05:57:10 +0000 (UTC) Message-ID: <001101c2e3a5$d507c380$c9c832c0@societykotla> From: "Aspire Something" To: "pgsql Sql" Subject: Arrays Or Loop Date: Thu, 6 Mar 2003 11:30:34 +0530 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_000E_01C2E3D3.CD3432F0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-HotPOP: ----------------------------------------------- Sent By HotPOP.com FREE Email Get your FREE POP email at www.HotPOP.com ----------------------------------------------- X-Archive-Number: 200303/164 X-Sequence-Number: 12204 This is a multi-part message in MIME format. ------=_NextPart_000_000E_01C2E3D3.CD3432F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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 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 =3D i ; if roll_data.class =3D 10 THEN do some work END IF; END LOOP; END; some more blahblah plpgsql ' Now my question is =3D> 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'=3D>'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. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D Some people think it's holding on that makes one strong; sometimes it's letting go. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D ------=_NextPart_000_000E_01C2E3D3.CD3432F0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi= all=20 ,

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

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

 Please pour in your valuable=20 knowledge

 Regards,
 V=20 Kashyap.

 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 Some people=20 think it's holding on that makes one strong;
sometimes  it's lettin= g=20 go.
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D



= ------=_NextPart_000_000E_01C2E3D3.CD3432F0--