[Tickets #6198] Re: One loop less

bugs at horde.org bugs at horde.org
Mon Feb 4 19:29:41 UTC 2008


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/?id=6198
-----------------------------------------------------------------------
 Ticket             | 6198
 Updated By         | Duck <duck at obala.net>
 Summary            | One loop less
 Queue              | Ansel
 Type               | Enhancement
 State              | Feedback
 Priority           | 1. Low
 Milestone          | 
 Patch              | 
 Owners             | Michael Rubinsky
-----------------------------------------------------------------------


Duck <duck at obala.net> (2008-02-04 14:29) wrote:

>> - Don't use SELECT *
>
> What's the rationale for this? In this case we actually do want all 
> the columns. Is there a performance issue with '*' vs putting all the 
> column names in the query explicitly?

One step less, some servers tends to access table headers to read column
list before processing the request.

>
>> - Combine the fetchAll db driver with the loop that creates 
>> galleries objects
>
> I don't see how this is reducing the number of loops, your just 
> replacing a for loop for a while loop from what I can tell. Also, 
> with your change we're no longer catching any errors that the 
> ->fetchAll() (->fetchRow() in your version) call can return.

The first loop is the fetchAll, the second create objects. With while you
fetch the result and create the object in one loop. If you wish, the row
variable can be checked for errors, but is not needed as the statement is
executed and checked before. With a little renaming of table columns the
parameters replace loop could be replace either. for example the
gallery_desc becomes gallers_description and you can select columns with
"AS" sql alias inside select statement. Reducing the attribute selection
only to one loop. Now the are 3, not needed.



More information about the bugs mailing list