Re: OOP slow -- am I an idiot?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

on 10/10/2006 08:14 PM Chris de Vidal said the following:
> I think perhaps I'm using classes and OOP incorrectly.  The last time
I used them, they were slow.

Your problem has nothing to do with OOP . It is the number of queries
that are making it solow. Creating an object takes microseconds.
Executing a query can take seconds.

Your greatest problem is that you use a query to retrieve each database
table row. If you want to retrieve many or all rows, a single query
approach is obviously much more efficient. That is true regardless you
use OOP to execute the queries or not.

The problem of using a lot of memory has only to do with using MySQL
buffered queries. You can also use unbuffered queries like with most
other databases but while your whole result set is not retrieved, it may
keep your database table locked.

Another detail, for retrieving large result sets with data from multiple
tables for reports or any other form of read only bulk processing, using
ORM (Object-relational mapping) is not very efficient. Retrieving whole
data into arrays with a single query is a more adequate solution.

On a related subject, you may want to take a look at a Metastorage. This
is an ORM class generator tool. For storing and retrieving single table
rows into objects, it generates simple ORM classes. But for read only
bulk data processing, it can generate what is called report classes.

These classes execute compiled SQL queries picking whatever columns and
conditions that match your needs and return the data in arrays either
all rows at once or a single row at a time.

http://www.metastorage.net/


-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux