varchar (no 'N') vs. text

Started by Jon Nelsonabout 15 years ago3 messagesgeneral
Jump to latest
#1Jon Nelson
jnelson+pgsql@jamponi.net

Let's say I have a database with two tables, a and b.
Each has one column. 'a' has a column 't' of type text. 'b' has a
column 'v' of type 'varchar' (no length specified).
If I join the two tables, I see in the plan something that looks like this:

Merge Cond: (a.t = (b.v)::text)

I thought 'character varying' (aka varchar) sans length was an alias
for text. Is it not?

--
Jon

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jon Nelson (#1)
Re: varchar (no 'N') vs. text

Jon Nelson <jnelson+pgsql@jamponi.net> writes:

I thought 'character varying' (aka varchar) sans length was an alias
for text. Is it not?

It has the same behavior, but it is a distinct type, so dummy coercions
are needed.

regards, tom lane

#3Jon Nelson
jnelson+pgsql@jamponi.net
In reply to: Tom Lane (#2)
Re: varchar (no 'N') vs. text

On Fri, Feb 4, 2011 at 1:18 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Jon Nelson <jnelson+pgsql@jamponi.net> writes:

I thought 'character varying' (aka varchar) sans length was an alias
for text. Is it not?

It has the same behavior, but it is a distinct type, so dummy coercions
are needed.

Are there any performance implications for this dummy coercion?
Especially in joins.

--
Jon