On May 13, 11:46 am, [email protected] (Aahz) wrote:
> In article <[email protected]>,
> Rob Williscroft  <[email protected]> wrote:
>
>
>
> >Aahz wrote innews:[email protected] comp.lang.python:
> >> In article <[email protected]>,
> >> Rob Williscroft  <[email protected]> wrote:
>
> >>>db.execute( '''
> >>>         update "sessions" set "uid" = ?
> >>>         where "uid" = ?
> >>>         and exists(
> >>>                  select * from "users" where "uid" = ?
> >>>           )
> >>>    ''',
> >>>    (v['uid'],s.SID, v['uid'])
> >>>  )
>
> >> This will be more efficient if you do "select uid from users".
>
> >What will be more efficient ?
>
> >Do you mean the "select * ..." or do you want to take the exists
> >sub-query out and put it in a python if ?
>
> "select uid" will be more efficient than "select *", although I suppose
> I could be wrong about that given how little I know about current query
> optimizers.

My take is that it won't matter what you select if the optimiser is
smart enough; something that requires minimal resources to produce is
indicated in case the optimiser is dumb:

 ... exists (select 1 from ... )

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to