postgres stored procedure or java code
I have a situation where there is large amount of data involved - about 开发者_Go百科a million rows. I need to perform some looping through results and have many nested loops. With Java, it is taking about 15 minutes to perform all the operations. Would it be noticeable faster if I used stored procedures? I am familiar with Java, but not stored procedures.
Using pl/* functions will usually be faster because it removes the overhead of going back and forth with the database server.
As an aside, note that you can use java to write the stored procedures in question:
http://pgfoundry.org/projects/pljava/
Lastly, try to rewrite part/all of what you're as a few big queries. It's usually faster to run a big query once than it is to loop through multitudes of small queries.
精彩评论