Jump to content

Sql Queries


adam84

Recommended Posts

Hi,

I am creating an application by using both PHP and mySQL. My question is about efficiency between PHP and mySQL. What would be a more efficient way of programming. To query the database and store the returned data in variables and perform the manicpulation on the variables. Or inser thte mathatical formula into your select statement and let mySQL handle the calculations? I search google and yahoo for this, but I was unable to find anything relevant.

Thanks
Link to comment
Share on other sites

[!--quoteo(post=389409:date=Jun 29 2006, 03:40 PM:name=adam84)--][div class=\'quotetop\']QUOTE(adam84 @ Jun 29 2006, 03:40 PM) [snapback]389409[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Hi,

I am creating an application by using both PHP and mySQL. My question is about efficiency between PHP and mySQL. What would be a more efficient way of programming. To query the database and store the returned data in variables and perform the manicpulation on the variables. Or inser thte mathatical formula into your select statement and let mySQL handle the calculations? I search google and yahoo for this, but I was unable to find anything relevant.

Thanks
[/quote]

There are people here who are more knowledgable then me on this topic, but php is one gigantic compiler reading and writing code on the fly (slow compared to a binary action like an sql transaction). I would think it would be much faster to do as much math as you can using sql (assuming it only takes 1 insert line) then to do it with php.

But the trade off is how many calculations you intend to preform. It might be easier from a maintenance point of view to use php.

I would think: use sql if it's a simple math that can be done without retrieving the info to work with first. Otherwise retrieve the record, do your math and insert the data back.

Chris
Link to comment
Share on other sites

The big performance hit is actually retrieving the result set itself... so if you're getting back hundreds of rows just to do some math, SQL is better; however, since it's just a bunch of statements, it becomes difficult to put together semantic data sets, so middleware if often the right choice.  It really depends.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.