[PERFORM] Indexing an array of two separate columns

Поиск
Список
Период
Сортировка
От Jeremy Finzel
Тема [PERFORM] Indexing an array of two separate columns
Дата
Msg-id CAMa1XUgw=G+8Tid=O30MScJZv4XCB7Pj3rX0rpoKo+Z0hZsmAQ@mail.gmail.com
обсуждение исходный текст
Список pgsql-performance
I have a user who is trying to match overlapping duplicate phone info but for different customer_ids.  

The intended conditional could be expressed: 
IF the intersection of the sets
{c.main_phone, c.secondary_phone}
and
{c1.main_phone, c1.secondary_phone}
is not empty 
THEN join 
EXCEPT where the intersection of the sets =
{'0000000000'}

He wants a join like this:

FROM customers c
INNER JOIN customers c1 on (array[c.main_phone, c.secondary_phone] &&  array[nullif(c1.main_phone, '0000000000') , nullif(c1.secondary_phone, '0000000000')])
(array[c.main_phone, c.secondary_phone] && array[nullif(c1.main_phone, '0000000000') , nullif(c1.secondary_phone, '0000000000')])
WHERE c.customer_id = 1;

I want to index this part:
array[nullif(c1.main_phone, '0000000000') , nullif(c1.secondary_phone, '0000000000')]

First of all I see I can't create a btree index on an array.  And with btree_gin, this index is not being used:

CREATE INDEX ON customers USING gin ((NULLIF(main_phone, '0000000000'::text)), (NULLIF(secondary_phone, '0000000000'::text)));

What am I missing here?  Is there a way to support a condition like this?

Thank you!

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [PERFORM] query of partitioned object doesnt use index in qa
Следующее
От: Mike Broers
Дата:
Сообщение: Re: [PERFORM] query of partitioned object doesnt use index in qa