Forum OpenACS Development: Re: String manipulation in Postgres

Collapse
Posted by Don Baccus on
All things being equal (i.e. both being equally efficient in string operations) doing it in the DB will be faster.

Why? Because only the exact string is returned by the query. In the second form, extra characters (those following 'csr_contact_') are returned into the Tcl string. Transferring those bytes has some cost, no matter how small.

So in essence you're guaranteed more byte-shuffling's going on in the second case.

But, I have no way of knowing if the assumption is correct (the "all things being equal" assumption).

In general I do stuff in the DB, and in general when I've seen people do much Tcl manipulation in db_multirow loops they seem to be relatively inefficient.