From: Sean Bowman <pico303@gmail.com>
To: Pavel B. Milovantsev <pav@enterprisewizard.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: imlicit varchar truncation
Date: Mon, 21 Mar 2011 09:55:30 -0600
Message-ID: <C9ACCEFB.5E7F%pico303@gmail.com> (raw)
In-Reply-To: <1300716597.3957.17.camel@pavhome.intis.tomsk.ru>
On 3/21/11 8:09 AM, "Pavel B. Milovantsev" <pav@enterprisewizard.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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: pico303@gmail.com, pav@enterprisewizard.com
Subject: Re: imlicit varchar truncation
In-Reply-To: <C9ACCEFB.5E7F%pico303@gmail.com>
References: <1300716597.3957.17.camel@pavhome.intis.tomsk.ru> <C9ACCEFB.5E7F%pico303@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox