[Solar-talk] select '*' vs. select $cols

Rodrigo Moraes rodrigo.moraes at gmail.com
Thu Feb 8 11:08:45 PST 2007


On 2/8/07, Paul M Jones wrote:
> One point:  the speed issue is not '*'/14 cols vs only 3 cols; it
> makes sense that selecting fewer cols is going to be faster.  I'd be
> more interested to see the speed diff between '*' and a list of all
> 14 cols.

I added a third select calling all 14 columns; in some of the
benchmarks it performed even worst than '*'. Check it:

http://solarphp.org/wiki/SandBox

> Second point: in the new Model, the relation definition allows you to
> specify which cols are selected from the foreign model.  However, the
> fetchAll()/fetchOne() on the Model itself still returns all the table
> cols.
>
> Are you suggesting that fetchAll(), fetchOne(), etc. should let you
> specify which columns are to be selected on a per-call basis?

Yes. It's useful and it's not difficult to add this.

> If so, I think those methods will need to start using an array for
> their params.  For example, right now, fetchAll() looks like this:
>
>      public function fetchAll($where, $order, $page)
>
> To facilitate a more workable collection of params, maybe we should
> do something like this:
>
>      public function fetchAll($params = array())
>
> The $params would be an array keyed on 'where', 'order', 'page',
> 'cols', etc.  The we don't have to worry about the order in which
> parameters appear.
>
> Would that make sense at all?

Yes; and you suggested this to the wrong person, because I like very
much to work with parameters as arrays like this, so I'm totally
biased. :) Indeed the parameters can grow and make the API ugly /
difficult to remember. An array as parameter is also good for
subclassing imo, but no matter if with an array or not I think we
should be able to restrict the selected columns in fetchs.

No big deal if this is not priority or adds much trouble, but honestly
I'll need to build a special version with this feature. It's a simple
change, anyway, so I'm suggesting and speculating so maybe others will
find this performance pepper interesting and I don't need to keep my
version for the model. :)

rodrigo
-------------------------------
http://tipos.com.br


More information about the solar-talk mailing list