Re: How are null's stored?

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: How are null's stored?
Дата
Msg-id 20030512160355.L17085-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на Re: How are null's stored?  (Josh Berkus <josh@agliodbs.com>)
Ответы Re: How are null's stored?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-performance
On Mon, 12 May 2003, Josh Berkus wrote:

> > So if the internal format is identical, why does the INFERNAL database
> > ignore indexes when you have a text compared to a varchar?
>
> I don't seem to have this problem; I use TEXT or VARCHAR willy-nilly,
> including in LIKE 'string%' and UPPER(field) queries, and the indexes work
> fine.

I can get the case he's complaining about with some cases I believe.

With an indexed varchar field, I can get 7.3.1 to give me:
sszabo=# set enable_seqscan=off;
SET
sszabo=# explain select * from aq2 where a=('f' || 'g');
                             QUERY PLAN
---------------------------------------------------------------------
 Seq Scan on aq2  (cost=100000000.00..100000022.50 rows=1 width=168)
   Filter: ((a)::text = 'fg'::text)

but

sszabo=# explain select * from aq2 where a=('f' || 'g')::varchar;
                              QUERY PLAN
----------------------------------------------------------------------
 Index Scan using aq2_pkey on aq2  (cost=0.00..4.82 rows=1 width=168)
   Index Cond: (a = 'fg'::character varying)

or

sszabo=# explain select * from aq2 where a=('f' || 'g'::varchar);
                              QUERY PLAN
----------------------------------------------------------------------
 Index Scan using aq2_pkey on aq2  (cost=0.00..4.82 rows=1 width=168)
   Index Cond: (a = 'fg'::character varying)

All in all, I'm not sure what the semantic differences between a varchar
with no length specified and a text are in PostgreSQL actually and if the
whole thing could be simplified in some way that doesn't break backwards
compatibility.


В списке pgsql-performance по дате отправления:

Предыдущее
От: Josh Berkus
Дата:
Сообщение: Re: How are null's stored?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: How are null's stored?