473,657 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Balancing speed against OO design - optimization issues with PHP/MySQL

Hi all, a request for opinions, please.

I am designing a smallish application to manage members of several
committees of a particula Organization. The structure of the system is as
follows:
theOrganization
contains Committees
which in turn contain People

So theOrganization object is a list of Committee objects which are
themselves groups of People objects.

Now, to get the data out of the MySQL database, it is probably more
efficient to do as few SQL selects as possible. Efficient from a speed
point of view. However, from a coding/OO-style point of view, it makes
more sense to have each People object be defined as *one* person -- but
that would mean that each has data for only one person and that would mean
a separate SELECT statement for each People object created. (Assuming that
there is a SQL SELECT in the constructor of each People object or
something similar to that).

Traditionally (i.e. non-OO), to code this, I would do as few SQL calls as
possible. But I can't see how to do that from an OO point of view.

For example, does it make sense to put all the people data into an array
outside of the People class and use this list to set up the class
constructor? (It doesn't make sense to me)

Or, for example, does it make sense to have the People class just be a
list of *everyone* in the people table? (This too does not make sense to
me)

On the other hand, what is the performance impact if I *do* make each
People class instance be only *one* person?

Allright, I hope this makes some sense. Thanks (in advance) for the advice!

--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website | http://www.wse.jhu.edu/newtnotes/

Jul 16 '05 #1
3 2142
"Jeffrey Silverman" <je*****@jhu.ed u> wrote in message
news:<pa******* *************** ******@jhu.edu> ...

I am designing a smallish application to manage members of several
committees of a particula Organization.
Notably missing from your description is the proposed functionality
of your software. In other words, you want suggestions as to HOW
to design the software without explaining WHAT this software has to
do.
The structure of the system is as follows:
theOrganization
contains Committees
which in turn contain People

So theOrganization object is a list of Committee objects which are
themselves groups of People objects.
Why even bother with 'theOrganizatio n' and 'Committee'? They are
nothing but simple arrays... Also, to make things worse, technically,
'theOrganizatio n' should be a singleton... :)
Now, to get the data out of the MySQL database, it is probably more
efficient to do as few SQL selects as possible. Efficient from a speed
point of view. However, from a coding/OO-style point of view, it makes
more sense to have each People object be defined as *one* person -- but
that would mean that each has data for only one person and that would mean
a separate SELECT statement for each People object created. (Assuming that
there is a SQL SELECT in the constructor of each People object or
something similar to that).

Traditionally (i.e. non-OO), to code this, I would do as few SQL calls as
possible. But I can't see how to do that from an OO point of view.
Which leads me to asking, why do you want OO design here in the first
place, if it is to result in lousy performance? Sounds like you are
deliberately setting yourself up for a failure...
For example, does it make sense to put all the people data into an array
outside of the People class and use this list to set up the class
constructor? (It doesn't make sense to me)

Or, for example, does it make sense to have the People class just be a
list of *everyone* in the people table? (This too does not make sense to
me)

On the other hand, what is the performance impact if I *do* make each
People class instance be only *one* person?


These questions would make sense if you were writing a desktop
application. But you're not; by choosing PHP as your development
tool, you have automatically abandoned the traditional concept of
application. You are not designing a monolythic package; rather,
you need to come up with a collection of relatively independent
utilities or modules, each suited for a narrowly defined task.
Until you figure out what those tasks are, you won't be able
to come up with a decent design.

Cheers,
NC
Jul 16 '05 #2
Hi Jeffrey
I am designing a smallish application to manage members of several
committees of a particula Organization. The structure of the system is as
follows:
theOrganization
contains Committees
which in turn contain People

So theOrganization object is a list of Committee objects which are
themselves groups of People objects.

Now, to get the data out of the MySQL database, it is probably more
efficient to do as few SQL selects as possible.
&c


Don't struggle with this.

Design your objects with a proper hierarchy.
Trust your database engine - you have no choice unless you build it
yourself.
Address the database engine properly using your preferred language with
correct reference objects.

And get on with things. :-)

Best regards,
Neil
Jul 16 '05 #3
On Mon, 11 Aug 2003 23:39:11 +0100, Neil White wrote:

<snip!>
Don't struggle with this.

okay, thanks, I won't
Design your objects with a proper hierarchy. Trust your database engine -
you have no choice unless you build it yourself.
Address the database engine properly using your preferred language with
correct reference objects.

And get on with things. :-)


Okay, thanks. In fact, I already have. And it turns out that I think I was
needlessly concerned.

But that's okay -- I just wanted some general opinions in this regard. And
I got some.

later...

--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website | http://www.wse.jhu.edu/newtnotes/

Jul 16 '05 #4

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

Similar topics

6
6869
by: J. Campbell | last post by:
Hi everyone. I'm sure that this is common knowledge for many/most here. However, it was rather illuminating for me (someone learning c++) and I thought it might be helpful for someone else. I'm sure I'll get scolded for an OT post, but I think issues of this type should be of interest to programmers until they get a handle on them. I was reading some old threads about the relative advantages of using ++i vs i++ (I won't rehash the many...
3
5160
by: Shabam | last post by:
When a web application becomes overloaded with traffic, one can offload it by load balancing and clustering the front end web servers. What happens when the back-end MSSQL database becomes overloaded? Does MYSQL offer load balancing and clustering?
40
3021
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the goodness of Python whenever I talk with fellow developers, but I always hit a snag when it comes to discussing the finer points of the execution model (specifically, exceptions). Without fail, when I start talking with some of the "old-timers"...
43
2825
by: Davey | last post by:
I am planning on developing an application which will involve skills that I have very little experience of - therefore I would appreciate comments on my initial design thoughts. Overview on system: I'm not going to divulge the exact aims of the application but the purpose of it is to allow multiple client applications to retrieve data from a database (on a db server) and feed this data into another Windows
7
3040
by: YAZ | last post by:
Hello, I have a dll which do some number crunching. Performances (execution speed) are very important in my application. I use VC6 to compile the DLL. A friend of mine told me that in Visual studio 2003 .net optimization were enhanced and that i must gain in performance if I switch to VS 2003 or intel compiler. So I send him the project and he returned a compiled DLL with VS 2003. Result : the VS 2003 compiled Dll is slower than the VC6...
10
2643
by: GeekBoy | last post by:
Okay, I have two identical web servers running Windows 2003 web server. I have an ASP.NET application which runs great on one of them. Dedicated IP address, behind our firewall, etc. Everyone's happy. Now -- how do I take advantage of that second computer to "load-balance" the web site? Will it really give my users a noticable performance increase? How do you accomplish this? I've read many of those MS articles and it's...
7
3099
by: Michael | last post by:
I'm writing an application that decodes a file containing binary records. Each record is a particular event type. Each record is translated into ASCII and then written to a file. Each file contains the same events. At the moment each record is processed one after the other. It taks about 1m40s to process a large file containing 70,000 records. Would my application benifit from multiple threads and mmap? If so what is the best way to...
12
2302
by: PD | last post by:
I am currently making a dating website. I want to have some information on how to structure the database and the php files so that I can achieve speed and efficiency. Can some one please give me suggestions and point me to references where I can get this information.
4
2047
by: Pseudonyme | last post by:
Dear Sirs and Madams, Receive as information that storing a MYSQL result under $_SESSION was accelerating web page displays processes ? Absolutly needed but impossible to get this working ! I try, but do not succeed in implement $_SESSION with MYSQL. <?php session_start();
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7347
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6175
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.