pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Update 3 columns w/ 1 function calc 3 values?
4+ messages / 4 participants
[nested] [flat]

* Update 3 columns w/ 1 function calc 3 values?
@ 2006-10-03 14:55  paallen@attglobal.net
  0 siblings, 3 replies; 4+ messages in thread

From: paallen@attglobal.net @ 2006-10-03 14:55 UTC (permalink / raw)
  To: pgsql-sql

Hi all,

I am moving some of my old MS Access functions to
plpgsql.

My function was made to return coordinates, X,Y,Z
for a point along a curved line.  So it is not the
fastest of functions because it has to call and
query data from 3 different tables.  I used to
just create 3 wrapper functions for my main
function which would return the x, y, and z values
seperately but that requires the main function to
be called 3 seperate times.  So here is my bottle
neck.  Of course I need to update +50,000 records.

What should I do to speed this up.  What is the
best way to update 3 columns from one function
call.  In MSACCESS I once rig the function to
cycle through the records with a curser but that
was slow and would crap out due to the shear number.

Thanks,

Phil 




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

* Re: Update 3 columns w/ 1 function calc 3 values?
@ 2006-10-03 15:19  William Leite Araújo <william.bh@gmail.com>
  parent: paallen@attglobal.net
  2 siblings, 0 replies; 4+ messages in thread

From: William Leite Araújo @ 2006-10-03 15:19 UTC (permalink / raw)
  To: paallen@attglobal.net <paallen@attglobal.net>; +Cc: pgsql-sql

2006/10/3, paallen@attglobal.net <paallen@attglobal.net>:
>
> Hi all,
>
> I am moving some of my old MS Access functions to
> plpgsql.
>
> My function was made to return coordinates, X,Y,Z
> for a point along a curved line.  So it is not the
> fastest of functions because it has to call and
> query data from 3 different tables.  I used to
> just create 3 wrapper functions for my main
> function which would return the x, y, and z values
> seperately but that requires the main function to
> be called 3 seperate times.  So here is my bottle
> neck.  Of course I need to update +50,000 records.
>
> What should I do to speed this up.  What is the
> best way to update 3 columns from one function
> call.


     It's realy very hard say something without the involving tables schema.

     You can:
        - change the function to return x,y,z in one call only ?
        - join the tables?
        - what is the function language?


In MSACCESS I once rig the function to
> cycle through the records with a curser but that
> was slow and would crap out due to the shear number.
>
> Thanks,
>
> Phil
>



-- 
William Leite Araújo

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

* Re: Update 3 columns w/ 1 function calc 3 values?
@ 2006-10-03 17:19  Bruno Wolff III <bruno@wolff.to>
  parent: paallen@attglobal.net
  2 siblings, 0 replies; 4+ messages in thread

From: Bruno Wolff III @ 2006-10-03 17:19 UTC (permalink / raw)
  To: paallen@attglobal.net; +Cc: pgsql-sql

On Tue, Oct 03, 2006 at 14:55:55 +0000,
  paallen@attglobal.net wrote:
> My function was made to return coordinates, X,Y,Z
> for a point along a curved line.  So it is not the
> fastest of functions because it has to call and
> query data from 3 different tables.  I used to
> 
> What should I do to speed this up.  What is the
> best way to update 3 columns from one function
> call.  In MSACCESS I once rig the function to
> cycle through the records with a curser but that
> was slow and would crap out due to the shear number.

Why is the data in three different tables? It is unusual to not have all
coordinates in the same table using one column per coordinate.

If you need to update 3 tables, you will need 3 update statements.
Doing all of the updates in a single transaction will help.
If possible doing all of the updates for each coordinate table in one command
will help. To do that you would need the data to be coming from data already
in the database.
Chnaging the design of your database so that the coordinates are all in the
same table (assuming that is possible) would be a good idea.



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

* Re: Update 3 columns w/ 1 function calc 3 values?
@ 2006-10-04 16:36  Markus Schaber <schabi@logix-tt.com>
  parent: paallen@attglobal.net
  2 siblings, 0 replies; 4+ messages in thread

From: Markus Schaber @ 2006-10-04 16:36 UTC (permalink / raw)
  To: paallen@attglobal.net; +Cc: pgsql-sql

Hi, paallen,

paallen@attglobal.net wrote:

> I am moving some of my old MS Access functions to
> plpgsql.
> 
> My function was made to return coordinates, X,Y,Z
> for a point along a curved line. 

Depending on the actual kind of data, you might want to look into the
PostgeSQL geometry types, or PostGIS for your geometric data.

> What should I do to speed this up.  What is the
> best way to update 3 columns from one function
> call.  In MSACCESS I once rig the function to
> cycle through the records with a curser but that
> was slow and would crap out due to the shear number.

It might work to mark the function as "stable", and have it return a
compound type in a subselect with an "AS foo" aliasname. Then you should
be able to address the compound's elements via foo.x, foo.y and foo.z.

Or use PostGIS, it's capable of processing 3D points.

HTH,
Markus

-- 
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf.     | Software Development GIS

Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org



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


end of thread, other threads:[~2006-10-04 16:36 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-10-03 14:55 Update 3 columns w/ 1 function calc 3 values? paallen@attglobal.net
2006-10-03 15:19 ` William Leite Araújo <william.bh@gmail.com>
2006-10-03 17:19 ` Bruno Wolff III <bruno@wolff.to>
2006-10-04 16:36 ` Markus Schaber <schabi@logix-tt.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