Re: PostgreSQL does CAST implicitely between int and a domain derived from int

От: Jean-Michel Pouré
Тема: Re: PostgreSQL does CAST implicitely between int and a domain derived from int
Дата: ,
Msg-id: 1251579586.11765.14.camel@acer
(см: обсуждение, исходный текст)
Ответ на: Re: PostgreSQL does CAST implicitely between int and a domain derived from int  (Tom Lane)
Ответы: Re: PostgreSQL does CAST implicitely between int and a domain derived from int  (Tom Lane)
Список: pgsql-performance

Скрыть дерево обсуждения

Re: PostgreSQL does CAST implicitely between int and a domain derived from int  ("Kevin Grittner", )
 Re: PostgreSQL does CAST implicitely between int and a domain derived from int  ("Kevin Grittner", )
  Re: PostgreSQL does CAST implicitely between int and a domain derived from int  (Jean-Michel Pouré, )
   Re: PostgreSQL does CAST implicitely between int and adomain derived from int  ("Kevin Grittner", )
    Re: PostgreSQL does CAST implicitely between int and adomain derived from int  (Jean-Michel Pouré, )
     Re: PostgreSQL does CAST implicitely between int andadomain derived from int  ("Kevin Grittner", )
      Re: PostgreSQL does CAST implicitely between int andadomain derived from int  (Jean-Michel Pouré, )
       Re: PostgreSQL does CAST implicitely between int and a domain derived from int  ("Kevin Grittner", )
        Re: PostgreSQL  (Jean-Michel Pouré, )
        Re: PostgreSQL does CAST implicitely between int and a domain derived from int  (Robert Haas, )
         Re: PostgreSQL does CAST implicitely between int and a domain derived from int  (Tom Lane, )
          Re: PostgreSQL does CAST implicitely between int and a domain derived from int  (Jean-Michel Pouré, )
           Re: PostgreSQL does CAST implicitely between int and a domain derived from int  (Bruce Momjian, )
            Re: PostgreSQL does CAST implicitely between int and a domain derived from int  (Jean-Michel Pouré, )
             Re: PostgreSQL does CAST implicitely between int and a domain derived from int  (Tom Lane, )
              Re: PostgreSQL does CAST implicitely between int and a domain derived from int  (Jean-Michel Pouré, )
               Re: PostgreSQL does CAST implicitely between int and a domain derived from int  (Tom Lane, )
                Re: PostgreSQL does CAST implicitely between int and a domain derived from int  (Greg Stark, )
         Re: PostgreSQL does CAST implicitely between int and a domain derived from int  (Jean-Michel Pouré, )
 Re: PostgreSQL does CAST implicitely between int and a domain derived from int  (Jean-Michel Pouré, )
  Re: PostgreSQL does CAST implicitely between int and adomain derived from int  ("Kevin Grittner", )
   Re: PostgreSQL does CAST implicitely between int and adomain derived from int  (Jean-Michel Pouré, )

Le samedi 29 août 2009 à 13:44 -0400, Tom Lane a écrit :
> That domain doesn't have any operators of its own.  To compare to
> another value, or use an index, you have to cast it to integer which
> does have operators.  It's a no-op cast, but logically necessary.

Dear Tom,

Thanks for answering. On more question:

Drupal makes use these no-op CREATE DOMAINs in the database schema :

CREATE DOMAIN int_unsigned
  AS integer
   CONSTRAINT int_unsigned_check CHECK ((VALUE >= 0));

CREATE DOMAIN bigint_unsigned
  AS bigint
   CONSTRAINT bigint_unsigned_check CHECK ((VALUE >= 0));

CREATE DOMAIN smallint_unsigned
  AS smallint
   CONSTRAINT smallint_unsigned_check CHECK ((VALUE >= 0));

CREATE DOMAIN varchar_ci
  AS character varying(255)
  DEFAULT ''::character varying
  NOT NULL;

In my slow queries, I can notice excessive no-op casts. Do you think
this could lead to excessive sequential scans?

What do you recommend: using normal types and moving constraints in the
Drupal database? Is PostgreSQL domain broken as it forces casting or is
this a no-op for performance?

What do you recommend?

Kind regards,
Jean-Michel

Вложения

В списке pgsql-performance по дате сообщения:

От: Jeff Janes
Дата:
Сообщение: Re: What exactly is postgres doing during INSERT/UPDATE ?
От: Merlin Moncure
Дата:
Сообщение: Re: What exactly is postgres doing during INSERT/UPDATE ?