Subject | With Subquery, Master table is not using index |
---|---|
Author | ibrahim bulut |
Post date | 2005-01-05T11:49:48Z |
Hi,
i am using firebird 1.5.2
i have a problem about subquery and index using
i have a table for stock details and another table for stocks.
stock detail table is indexed with stokck_id.
the query is that
SELECT STOCK_ID, TRDATE, TRTIME, AMOUNT, TOTAL FROM STOCK_DETAIL
WHERE STOCK_ID IN (SELECT STOCK_TYPE IN (1,2,3,4,5))
this query returns this plan
STOCK_DETAIL Natural, STOCK X_STYPE
but if i use this query
SELECT STOCK_ID, TRDATE, TRTIME, AMOUNT, TOTAL FROM STOCK_DETAIL
WHERE STOCK_ID IN (15,250,125)
plan is that
STOCK_DETAIL XSD_STOCK_ID,XSD_STOCK_ID,XSD_STOCK_ID
how can i solve this problem
can i use my own plan for the first query
how can i use the index
i am using firebird 1.5.2
i have a problem about subquery and index using
i have a table for stock details and another table for stocks.
stock detail table is indexed with stokck_id.
the query is that
SELECT STOCK_ID, TRDATE, TRTIME, AMOUNT, TOTAL FROM STOCK_DETAIL
WHERE STOCK_ID IN (SELECT STOCK_TYPE IN (1,2,3,4,5))
this query returns this plan
STOCK_DETAIL Natural, STOCK X_STYPE
but if i use this query
SELECT STOCK_ID, TRDATE, TRTIME, AMOUNT, TOTAL FROM STOCK_DETAIL
WHERE STOCK_ID IN (15,250,125)
plan is that
STOCK_DETAIL XSD_STOCK_ID,XSD_STOCK_ID,XSD_STOCK_ID
how can i solve this problem
can i use my own plan for the first query
how can i use the index