Обсуждение: Update 3 columns w/ 1 function calc 3 values?
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
2006/10/3, paallen@attglobal.net <paallen@attglobal.net>:
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?
--
William Leite Araújo
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
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.
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