Re: joining an array with a table or...?

Поиск
Список
Период
Сортировка
От Ivan Sergio Borgonovo
Тема Re: joining an array with a table or...?
Дата
Msg-id 20091026204821.0d5b4683@dawn.webthatworks.it
обсуждение исходный текст
Ответ на Re: joining an array with a table or...?  (Merlin Moncure <mmoncure@gmail.com>)
Ответы Re: joining an array with a table or...?  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
On Mon, 26 Oct 2009 14:56:26 -0400
Merlin Moncure <mmoncure@gmail.com> wrote:

> On Mon, Oct 26, 2009 at 11:05 AM, Ivan Sergio Borgonovo
> <mail@webthatworks.it> wrote:
> > To make it more concrete I came up with:
> >
> > select coalesce(u.mail,j.mail) from (
> >  select (array['m@example1.com','m@example2.com'])[i] as mail
> >   from generate_series(1,2) i) j
> >   left join users u on upper(u.mail)=upper(j.mail);
>
> how about this:
> select coalesce(u.mail,j.mail) from
> (
>  values ('m@example1.com'), ('m@example2.com')
> ) j(mail)
>  left join users u on upper(u.mail)=upper(j.mail);

Yours is between 4 to 10 times faster excluding time on client side
to escape the strings.

I'll play a bit with client code to see if the advantage is kept.

It looks nicer too.

Currently I'm testing with very few match between input array and
user table.
Will this have different impact on the 2 methods?

thanks

--
Ivan Sergio Borgonovo
http://www.webthatworks.it


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

Предыдущее
От: Vick Khera
Дата:
Сообщение: Re: Postmaster taking 100% of the CPU
Следующее
От: Vick Khera
Дата:
Сообщение: Re: How to list user-specific configuration parameters?