If your do have a long record list here are some speed tips.

if you do not need to, don't use distinct:

tags = ', '.join(t.name for t in db().select(db.tag.name)

if you need distinct but you are not already doing and orderering on that
column, use a group by:

tags = ', '.join(t.name for t in db().select(db.tag.name,groupby=db.tag.name
))

group by is more efficient than distinct on many databases, not all, so
YMMV.

mic


2012/11/28 Massimo Di Pierro <[email protected]>

> tags = ', '.join(t.name for t in db().select(db.tag.name,distinct=True))
>
>
> On Tuesday, 27 November 2012 11:48:00 UTC-6, Rod Watkins wrote:
>>
>> I need to create a comma separated list of tags from the rows returned
>> from a tags table.
>>
>> This is how I am doing it now, but it seems wasteful. There must be a
>> better way.
>>
>> tag_db = db(db.tag.id>0).select(db.tag.**name <http://db.tag.name>)
>> tag_list = []
>>     for t in tag_db:
>>         tag_list.append(t.name)
>> tags = ", ".join(tag_list)
>>
>> Thanks
>> Rod
>>
>>  --
>
>
>
>

-- 



Reply via email to