[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3318) Allow omitting varchar limit by default in PostgreSQL

Charles Gutjahr (JIRA) noreply at atlassian.com
Wed Sep 14 02:19:02 EDT 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43510#comment-43510 ] 

Charles Gutjahr commented on HHH-3318:
--------------------------------------

I agree with this change. In fact the PostgreSQL documentation _recommends_ that {{text}} be used instead of {{character(255)}} because {{text}} is faster. (Note that {{varchar}} used by Hibernate is a synonym for {{character}}.)

Here's what the PostgreSQL documentation says:
{quote}
While character\(n\) has performance advantages in some other database systems, there is no such advantage in PostgreSQL; in fact character\(n\) is usually the slowest of the three because of its additional storage costs. In most situations text or character varying should be used instead.
http://www.postgresql.org/docs/9.1/static/datatype-character.html
{quote}

> Allow omitting varchar limit by default in PostgreSQL
> -----------------------------------------------------
>
>                 Key: HHH-3318
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3318
>             Project: Hibernate Core
>          Issue Type: New Feature
>          Components: core
>         Environment: Hibernate 3.2.6, PostgreSQL 8.3.1
>            Reporter: Luke Maurer
>            Priority: Minor
>
> Essentially, what I'd like is for a String without a given maximum length be mapped as a varchar or text rather than a varchar(255) as is now the case. The maximum doesn't do anything to improve performance or storage efficiency in PostgreSQL, so varchar(255) merely imposes an arbitrary constraint. It would be more idiomatic to use varchar where no limit is given, leaving varchar(n) for cases where the length is limited as a business rule rather than an implementation detail.
> (Naturally, one can always use @Lob where it's actually *important* that the column be a varchar or text. So this is definitely minor.)

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list