Zeugswetter Andreas ADI SD wrote:
Thats exactly the point. Consider
select mytext from mytable ;

How can PostgreSQL possibly know the maximum length of the returned values *before* it has scanned the whole table?

I think this focuses too much on those cases where it is not possible.
When it is not feasible like with a text column, clients deal with it
already (obviously some better than others). It is for those cases where it would be feasible, like constants (or
concateneted columns), where the max length if properly returned could
be used to improve performance.

I doubt there's any measurable performance benefit here. You might as well allocate a buffer of say 128 bytes, and enlarge it from there when you see a value larger than that. Even in the worst case, you'll only need to enlarge the buffer a few times per query until you reach the real max length.

Actually, if you're in such a high throughput, client-side CPU-intensive situation that this makes any difference, why are you copying the value to another buffer in the first place? Just access it directly in the libpq buffer returned by PQgetvalue, and move on.

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

               http://www.postgresql.org/about/donate

Reply via email to