pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Arrays Or Loop
2+ messages / 2 participants
[nested] [flat]

* Arrays Or Loop
@ 2003-03-06 06:00 Aspire Something <aspire420@hotpop.com>
  2003-03-06 17:17 ` Re: Arrays Or Loop Josh Berkus <josh@agliodbs.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Aspire Something @ 2003-03-06 06:00 UTC (permalink / raw)
  To: 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.

 ================================
 Some people think it's holding on that makes one strong;
sometimes  it's letting go.
 ================================

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Arrays Or Loop
  2003-03-06 06:00 Arrays Or Loop Aspire Something <aspire420@hotpop.com>
@ 2003-03-06 17:17 ` Josh Berkus <josh@agliodbs.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Josh Berkus @ 2003-03-06 17:17 UTC (permalink / raw)
  To: Aspire Something <aspire420@hotpop.com>; pgsql-sql

Aspire,

>  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.

Unfortunately, the current version of PL/pgSQL have problems with array 
support.  So if you want to test this with arrays, you will have to use 
another language, such as C or Python.

>  4. Lastly if i use views will they help in fas execution

No.   If you want fast execution, try writing the procedure in C.

-- 
Josh Berkus
Aglio Database Solutions
San Francisco



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-03-06 17:17 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-03-06 06:00 Arrays Or Loop Aspire Something <aspire420@hotpop.com>
2003-03-06 17:17 ` Josh Berkus <josh@agliodbs.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox