pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Achilleus Mantzios <achill@matrix.gatewaynet.com>
To: Josh Berkus <josh@agliodbs.com>
Cc: Wei Weng <wweng@kencast.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: text vs varchar
Date: Wed, 19 Jun 2002 10:44:03 +0300 (EEST)
Message-ID: <Pine.LNX.4.44.0206191042150.7003-100000@matrix.gatewaynet.com> (raw)
In-Reply-To: <200206181559.54654.josh@agliodbs.com>

On Tue, 18 Jun 2002, Josh Berkus wrote:

> Wei,
> 
> > Is there any disadvantage of using TEXT datatype as opposed to a VARCHAR
> > datatype with a maximum length, especially when I do searches on them?
> 
> Yes.  You can't index TEXT because it's of potentially unlimited length.

Well indexing text works fine for me.

                      Table "repdat"
     Column      |            Type             | Modifiers
-----------------+-----------------------------+-----------
 vslid           | integer                     |
 vslname         | character varying(15)       |
 orderno         | integer                     | not null
 date_in         | timestamp without time zone |
 port_landed     | character varying(15)       |
 subject         | text                        |
 catid           | integer                     |

dynacom=# EXPLAIN ANALYZE SELECT subject from repdat where subject='UTM 
FOR SPECIAL SURVEY JUNE2000';
NOTICE:  QUERY PLAN:
 
Index Scan using repdat_subject_idx on repdat  (cost=0.00..7.40 rows=1 
width=28) (actual time=0.05..0.06 rows=1 loops=1)
Total runtime: 0.10 msec
 
EXPLAIN
dynacom=#
dynacom=# SET enable_indexscan = off;
SET VARIABLE
dynacom=# EXPLAIN ANALYZE SELECT subject from repdat where subject='UTM 
FOR SPECIAL SURVEY JUNE2000';
NOTICE:  QUERY PLAN:
 
Seq Scan on repdat  (cost=0.00..388.59 rows=1 width=28) (actual 
time=0.03..8.14
rows=1 loops=1)
Total runtime: 8.19 msec
 
EXPLAIN
dynacom=#
> 
> 

-- 
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
tel:    +30-10-8981112
fax:    +30-10-8981877
email:  achill@matrix.gatewaynet.com
        mantzios@softlab.ece.ntua.gr




view thread (6+ messages)

Message-ID: <Pine.LNX.4.44.0206191042150.7003-100000@matrix.gatewaynet.com>
Permalink:  ../Pine.LNX.4.44.0206191042150.7003-100000@matrix.gatewaynet.com/
Also on:    postgresql.org/message-id/Pine.LNX.4.44.0206191042150.7003-100000@matrix.gatewaynet.com

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: achill@matrix.gatewaynet.com, josh@agliodbs.com, wweng@kencast.com
  Subject: Re: text vs varchar
  In-Reply-To: <Pine.LNX.4.44.0206191042150.7003-100000@matrix.gatewaynet.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