Re: [firebird-support] Why index is not used in this query?

2015-05-16 Thread Svein Erling Tysvær svein.erling.tysv...@kreftregisteret.no [firebird-support]
SELECT * FROM TABLE_2 T2 INNER JOIN TABLE_1 T1 ON T2.TABLE_1_ID = T1.ID After executing this query I am getting such plan: PLAN JOIN (T1 NATURAL, T2 INDEX (FK_TABLE_2)) Why in case of TABLE_1 optimizer did not chose index PK_TABLE_1? And why I am getting error when i try to enforce it

[firebird-support] Why index is not used in this query?

2015-05-15 Thread brucedickin...@wp.pl [firebird-support]
Hello, here is full example: CREATE TABLE TABLE_1 ( ID INTEGER NOT NULL, NAME VARCHAR(32), CONSTRAINT PK_TABLE_1 PRIMARY KEY (ID) ); GRANT DELETE, INSERT, REFERENCES, SELECT, UPDATE ON TABLE_1 TO SYSDBA WITH GRANT OPTION; CREATE TABLE TABLE_2 ( ID INTEGER NOT NULL,

Re: [firebird-support] Why index is not used in this query?

2015-05-15 Thread Tim Ward t...@telensa.com [firebird-support]
How about something along the lines of: A table that small is going to fit into a single disk page. So a table scan involves reading one disk page. Using the index would involve reading the index as well, which is a second disk page, so twice as slow. ? (Other RDBMS which have a covering

Re: [firebird-support] Why index is not used in this query?

2015-05-15 Thread Ann Harrison aharri...@ibphoenix.com [firebird-support]
On May 15, 2015, at 9:02 AM, brucedickin...@wp.pl [firebird-support] firebird-support@yahoogroups.com wrote: SELECT * FROM TABLE_2 T2 INNER JOIN TABLE_1 T1 ON T2.TABLE_1_ID = T1.ID After executing this query I am getting such plan: PLAN JOIN (T1 NATURAL, T2 INDEX

RE: [firebird-support] Why index is not used in this query?

2015-05-15 Thread 'Leyne, Sean' s...@broadviewsoftware.com [firebird-support]
Bruce, SELECT * FROM TABLE_2 T2   INNER JOIN TABLE_1 T1  ON T2.TABLE_1_ID = T1.ID After executing this query I am getting such plan: PLAN JOIN (T1 NATURAL, T2 INDEX (FK_TABLE_2)) Why in case of TABLE_1 optimizer did not chose index PK_TABLE_1? Given that there is no ORDER BY clause