Re: imlicit varchar truncation

From: Sean Bowman <pico303(at)gmail(dot)com>
To: "Pavel B(dot) Milovantsev" <pav(at)enterprisewizard(dot)com>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: imlicit varchar truncation
Date: 2011-03-21 15:55:30
Message-ID: C9ACCEFB.5E7F%pico303@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On 3/21/11 8:09 AM, "Pavel B. Milovantsev" <pav(at)enterprisewizard(dot)com>
wrote:

>I have to perform an additional call to
>connection.getMetaData().getColumns()
>in order to obtain the size of inserted/updated varchar field, and either
>truncate the value at the client side, or make explicit truncations as
>shown
>at (http://www.postgresql.org/docs/9.0/static/datatype-character.html)
>
>The question is, are there any "standard" ways to avoid this excessive
>call?
> Have to say that a hand-made DB scheme caching is not the option.
>

This is how I've always done it.

Though are you saying you can't load your database schema when the
application starts and cache the lengths of all the varchars? Is your
schema that dynamic, that it changes while the application is running?
You're on a dangerous path, my friend.

I'm not trying to be condescending, and I have no idea what the goal of
your app is so it may be appropriate, but 99.9% of the time you shouldn't
be creating new database tables or columns in your application on the fly.
If this is the case, you might want to sit down with a database expert
and examine your strategies. There may be a better way to model what
you're trying to accomplish and still get the performance for which you're
looking.

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message sdavidr 2011-03-23 23:35:57 Problems with Hibernate Discriminators and 9.0-801.jdbc4
Previous Message Pavel B. Milovantsev 2011-03-21 14:09:57 imlicit varchar truncation