473,508 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

best practice for use of functions..


My application does between 20-40 inserts per transaction. I am putting all
of them into functions to limit the calls from the DBI to the database.

My preferred method is to have a function for each table that I do an insert
into, it's easier to manage that way and a lot easier to make changes if I
add/drop columns and tables. Right now I have one function that is called
by my application that in turn calls all the other functions.

I am wondering is there is a significant overhead for calling say 10
functions from within a function compared to putting everything into one
single function? Or are there other reasons why I would want to do it
differently?

Chris

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 22 '05 #1
3 1241
"Chris Ochs" <ch***@paymentonline.com> writes:
My preferred method is to have a function for each table that I do an insert
into, it's easier to manage that way and a lot easier to make changes if I
add/drop columns and tables. Right now I have one function that is called
by my application that in turn calls all the other functions.

I am wondering is there is a significant overhead for calling say 10
functions from within a function compared to putting everything into one
single function?


Compared to the disk I/O overhead for a transaction, it'd be lost in
the noise--do whatever makes you happy. :)

-Doug

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 22 '05 #2
Aren't there some caveats to this related to transactions? I've been
working under the strong (I think I read.. heh) impression that
transactions cannot be nested, in 7.3 at least..

This would lead me to believe if the 'main' function called another that
failed and thus issued a rollback, would that not rollback the entire
meta-transaction, for lack of a better word?

-Allen

At 21:26 1/14/2004, Doug McNaught wrote:
"Chris Ochs" <ch***@paymentonline.com> writes:
My preferred method is to have a function for each table that I do an

insert
into, it's easier to manage that way and a lot easier to make changes if I
add/drop columns and tables. Right now I have one function that is called
by my application that in turn calls all the other functions.

I am wondering is there is a significant overhead for calling say 10
functions from within a function compared to putting everything into one
single function?


Compared to the disk I/O overhead for a transaction, it'd be lost in
the noise--do whatever makes you happy. :)

-Doug

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 22 '05 #3
On Thursday 15 January 2004 03:50, Allen Landsidel wrote:
Aren't there some caveats to this related to transactions? I've been
working under the strong (I think I read.. heh) impression that
transactions cannot be nested, in 7.3 at least..

This would lead me to believe if the 'main' function called another that
failed and thus issued a rollback, would that not rollback the entire
meta-transaction, for lack of a better word?


"multi-statement transaction" might be the better word. Now need a better word
for "a bunch of words strung together" ;-)

You're correct, but in this case Chris was doing a batch of inserts in the
same transaction anyway, so that's what he wants.
--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2609
by: Mark Twombley | last post by:
Hi, I'm just getting back into C++ and had a question about the best practice for assigning error numbers. I have been working in VB for sometime now and there you would start assigning error...
136
9201
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
17
7999
by: | last post by:
I have an app that retrieves data from an Access database. At the moment I have the SQL string as a Const in my app. I understand this is not best practice. I don't want the user to have access to...
8
1768
by: Fredrik Melin | last post by:
I have a "Inventory" Object that contains the product and all its fields. The problem is that I am getting soooooo many functions under main Inventory class so it becames impossible to initalize...
16
2770
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
2
1650
by: dhable | last post by:
I'm developing a web system and based on some patterns I've seen elsewhere, I made a single file (model.py) to hold all of the functions and classes that define the model porition of the...
17
3008
by: 2005 | last post by:
Hi In C++, are the following considered best practices or not? - passing aguments to functions (ie functions do not take any arguments ) - returning values using return statement Anything...
4
2089
by: =?Utf-8?B?Sm9l?= | last post by:
I am working on a web app that required authentication to AD. The authentication is working fine the way I am doing it, but was wondering what the best practice is. My code doesn't actually...
52
3325
by: burgermeister01 | last post by:
First, let me say that this question is a rather general programming question, but the context is PHP, so I figured this group would have the most relevant insight. Anyways, this is also more of...
0
7224
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.