Re: [JDBC] Prepared Statements and large where-id-in constant blocks?

Поиск
Список
Период
Сортировка
От Oliver Jowett
Тема Re: [JDBC] Prepared Statements and large where-id-in constant blocks?
Дата
Msg-id 408491B1.20800@opencloud.com
обсуждение исходный текст
Ответ на Re: [JDBC] Prepared Statements and large where-id-in constant blocks?  (Oliver Jowett <oliver@opencloud.com>)
Ответы Re: [JDBC] Prepared Statements and large where-id-in constant blocks?
Список pgsql-sql
Oliver Jowett wrote:

> The CMP layer could perhaps use the = ANY array syntax and setArray()
> (note that setArray() in the current driver needs fixing, I have an old
> patch to do this):
>
>   SELECT t1.attr1 FROM t1 where t1.id = ANY (?)

Unfortunately a bit of experimentation indicates that the planner
doesn't do anything clever with ANY + constant array values (at least in
7.4.1 which is what I have to hand):

> test=> explain select * from test_array where i in (1,2,3,4,5);
>                                                                       QUERY PLAN
                                 
>
-------------------------------------------------------------------------------------------------------------------------------------------------------
>  Index Scan using test_array_pkey, test_array_pkey, test_array_pkey, test_array_pkey, test_array_pkey on test_array
(cost=0.00..15.12rows=5 width=4) 
>    Index Cond: ((i = 1) OR (i = 2) OR (i = 3) OR (i = 4) OR (i = 5))
> (2 rows)
>
> test=> explain select * from test_array where i = any ('{1,2,3,4,5}'::integer[]);
>                            QUERY PLAN
> ----------------------------------------------------------------
>  Seq Scan on test_array  (cost=0.00..807.80 rows=10240 width=4)
>    Filter: (i = ANY ('{1,2,3,4,5}'::integer[]))
> (2 rows)
>
> test=> select version();
>                                                      version
> ------------------------------------------------------------------------------------------------------------------
>  PostgreSQL 7.4.1 on i386-pc-linux-gnu, compiled by GCC i386-linux-gcc (GCC) 3.3.3 20040110 (prerelease) (Debian)
> (1 row)

-O


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

Предыдущее
От: Oliver Jowett
Дата:
Сообщение: Re: [JDBC] Prepared Statements and large where-id-in constant blocks?
Следующее
От: Martin Marques
Дата:
Сообщение: Re: Can someone tell me why this statement is failing?