Subject Re: Odp: [firebird-support] Indexes on subquery
Author hosodaamiya
Hi Karol,

Thanks for your reply.

I use Firebird 2.5 Embedded.

My table Definition is as the following:
CREATE TABLE TEST
(
ID Bigint NOT NULL,
ID2 Bigint NOT NULL,
PRIMARY KEY (ID)
);
CREATE INDEX IDX_TEST1 ON TEST (ID2);
CREATE TABLE SUBQUERYTABLE
(
ID2 Bigint NOT NULL,
PRIMARY KEY (ID2)
);

And I have issued the following types of queries:

[Query1]
select id from TEST where id2 in (select id2 from subquerytable);
[Query plan]
Preparing query: select id from TEST where id2 in (select id2 from subquerytable)
Prepare time: 0.001s
Field #01: TEST.ID Alias:ID Type:BIGINT
PLAN (SUBQUERYTABLE INDEX (RDB$PRIMARY14))
PLAN (TEST NATURAL)
Script execution finished.

[Query2]
select id from TEST where id2 in (1,2);
[Query plan]
Preparing query: select id from TEST where id2 in (1,2)
Prepare time: 0.000s
Field #01: TEST.ID Alias:ID Type:BIGINT
PLAN (TEST INDEX (IDX_TEST1, IDX_TEST1))
Script execution finished.

IDX_TEST1 seems to be not used for Query1.
But it is used for Query2.
Is it unsuitable query syntax like Query1?


--- In firebird-support@yahoogroups.com, "liviuslivius@..." <liviuslivius@...> wrote:
>
> Hi,
>
> Subqueries uses indexes i "the same way" as primary query.
>
> Show us this subquery and query plan returned by server. Will be good to see also Firebird version 1.5, 2.1, 2.5?
>
> Regards,
> Karol Bieniaszewski
>
> ----- Reply message -----
> Od: "hosodaamiya" <s-hosoda@...>
> Do: <firebird-support@yahoogroups.com>
> Temat: [firebird-support] Indexes on subquery
> Data: pt., lis 29, 2013 04:00
> Hi all,
>
>
>
> Is it the designed behavior that indexes are not used in subquery?
>
> If it is desined at present, the function for index in subquery will be implemented in versions of the future?
>
>
>
> Regards,
>
> Shingo
>