Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id D372F1337BC8 for ; Mon, 21 Mar 2011 12:55:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 58851-02-9 for ; Mon, 21 Mar 2011 15:55:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-iy0-f174.google.com (mail-iy0-f174.google.com [209.85.210.174]) by mail.postgresql.org (Postfix) with ESMTP id 390F31337C01 for ; Mon, 21 Mar 2011 12:55:39 -0300 (ADT) Received: by iyb26 with SMTP id 26so6505001iyb.19 for ; Mon, 21 Mar 2011 08:55:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:user-agent:date:subject:from:to:message-id :thread-topic:in-reply-to:mime-version:content-type :content-transfer-encoding; bh=LdjJkITxicuM3kmbiii9fVWReUqR3jii0thzadJnv/k=; b=EQwMHEEHHXd0h1LNUP/RXFt4f6Rc4EXg6xtSG65ciU0K3iSK28MSytb/jxGrdGrr7T ijc85LFE/GoKV/6LtqDxmvzGTwzp8k1W/jC3ZC/9XMuByjZSCe7+cdCBnpVOZhrCyDze 2THnKlgR71iYLEc6iygOGVUu1ruu68eCPC+CE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=user-agent:date:subject:from:to:message-id:thread-topic:in-reply-to :mime-version:content-type:content-transfer-encoding; b=cN16sklEzmuGcg4Hsxboeq7DAn6bPkE09RojYZD0AWv+Ur2qIA3tYB6rdHETdM/7eB LhjRlRI9rDJEzkfd9d12Z9u9R98gX93gE4a8aRhnfjkC7ENdlOWtp9J2mlSEcriMC6ou cfe2ZvKQPUpG2vBBs8JIBhccIHB+gj/0HHW1E= Received: by 10.231.33.193 with SMTP id i1mr4281442ibd.199.1300722938173; Mon, 21 Mar 2011 08:55:38 -0700 (PDT) Received: from [10.0.0.2] ([65.100.168.215]) by mx.google.com with ESMTPS id he40sm3796413ibb.67.2011.03.21.08.55.36 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 21 Mar 2011 08:55:37 -0700 (PDT) User-Agent: Microsoft-MacOutlook/14.2.0.101115 Date: Mon, 21 Mar 2011 09:55:30 -0600 Subject: Re: imlicit varchar truncation From: Sean Bowman To: "Pavel B. Milovantsev" , Message-ID: Thread-Topic: [JDBC] imlicit varchar truncation In-Reply-To: <1300716597.3957.17.camel@pavhome.intis.tomsk.ru> Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.046 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=1.553, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7 X-Spam-Level: X-Archive-Number: 201103/40 X-Sequence-Number: 21595 On 3/21/11 8:09 AM, "Pavel B. Milovantsev" 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.