Re: Composite types questions

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Vincenzo Romano <vincenzo(dot)romano(at)notorand(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Composite types questions
Date: 2010-01-11 15:03:15
Message-ID: b42b73151001110703y5f31b45fi8223ea45a7fc747b@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jan 11, 2010 at 5:14 AM, Vincenzo Romano
<vincenzo(dot)romano(at)notorand(dot)it> wrote:
> Hi all.
>
> It's not clear to me how composite values are used in  conditions (WHERE/CHECK).
> In my case I have something like this:
>
> -- begin snippet
>
> CREATE TABLE test_tab (
>  col1 timestamp not null,
>  col2 int8 not null,
>  col3 text not null
> );
>
> CREATE INDEX i_test_tab_col1 ON test_tab( col1 );
>
> SELECT *
>  FROM test_tab
>  WHERE (date_trunc('week',col1),col2,col3)=('val1'::timestamp,val2,'val3')
> ;
> -- end snippet
>
> For a number of reasons I cannot split the the WHERE condition in the
> "usual" AND-list.
> My questions are:
> Can the i_test_tab_col1 INDEX be taken into account from the query planner?
me
yes

> What if I define a functional index on col1?

sure (if you pull the data the way it is done in the function)

> Does the same apply to TABLE-level CHECK conditions?

probably.

You are not really asking about composite types. What you
demonstrated is row constructor syntax...they are similar but not the
same. For the most part, at least from 8.2 onwards, postgres is
pretty smart about row constructor and should do what you want with
minimal fuss.

merlin

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-01-11 15:32:32 Re: pg.dropped
Previous Message Merlin Moncure 2010-01-11 14:58:41 Re: Set Returning C-Function with cache over multiple calls (with different arguments)