Professional Web Applications Themes

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

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 ...

  1. #1

    Default 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 | [url]http://www.wse.jhu.edu/newtnotes/[/url]

    Jeffrey Silverman Guest

  2. #2

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

    "Jeffrey Silverman" <jeffreyjhu.edu> wrote in message
    news:<pan.2003.08.11.15.14.03.382407jhu.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 'theOrganization' and 'Committee'? They are
    nothing but simple arrays... Also, to make things worse, technically,
    'theOrganization' 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
    Nikolai Chuvakhin Guest

  3. #3

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

    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


    Neil White Guest

  4. #4

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

    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 | [url]http://www.wse.jhu.edu/newtnotes/[/url]

    Jeffrey Silverman Guest

Similar Threads

  1. MySql tion and network speed
    By Chad J. Lemmer in forum MySQL
    Replies: 3
    Last Post: January 29th, 06:33 PM
  2. Cfdoent Speed issues
    By StokeyTCI in forum Coldfusion - Advanced Techniques
    Replies: 8
    Last Post: April 4th, 03:04 PM
  3. Replies: 3
    Last Post: February 13th, 06:28 AM
  4. Horrible Speed issues? Win2k P4 2Ghz Machine
    By bshroyer webforumsuser@macromedia.com in forum Macromedia Fireworks
    Replies: 3
    Last Post: September 26th, 03:22 PM
  5. Database design/optimization question
    By AMIT in forum Microsoft SQL / MS SQL Server
    Replies: 0
    Last Post: July 1st, 07:02 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139