New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Same SELECT with 3.0.2 uses different PLAN as 2.0.3 (and takes much longer) [CORE5557] #5824
Comments
Commented by: @dyemanov What are the data types of KIADT.KIADF_SIF and TMPSYNC.SIF? Are they same or different? |
Commented by: Pósa József (posaj) Dear Dmitry, KIADT.KIADF_SIF: INTEGER Earlier I made a test with SELECT * FROM KIADT WHERE KIADF_SIF IN (SELECT CAST(SIF AS INTEGER) SIF FROM TMPSYNC), without acceptable result. Plan Adapted Plan ------ Performance info ------ thanks again. |
Modified by: Pósa József (posaj)description: Executing SELECT * FROM KIADT WHERE KIADF_SIF IN (SELECT SIF FROM TMPSYNC) command take 125 mses on 2.0.3 and 1 min 13 sec on 3.0.2. Firebird 2.0.3: Plan Adapted Plan ------ Performance info ------ Firebird 3.0.2: Plan ------ Performance info ------ => Executing SELECT * FROM KIADT WHERE KIADF_SIF IN (SELECT SIF FROM TMPSYNC) command take 125 msec on 2.0.3 and 1 min 13 sec on 3.0.2. Firebird 2.0.3: Plan Adapted Plan ------ Performance info ------ Firebird 3.0.2: Plan ------ Performance info ------ summary: Same SELECT with 3.0.2 uses different PLAN as 2.0.3 (and takes much loner) => Same SELECT with 3.0.2 uses different PLAN as 2.0.3 (and takes much longer) |
Commented by: @dyemanov So it's not a bug but expected (for incompatible data types). Your original query should look like: SELECT * FROM KIADT WHERE CAST(KIADF_SIF AS VARCHAR(32)) IN (SELECT SIF FROM TMPSYNC) to be fast, but double check that your values inside TMPSYNC.SIF are really simple numbers and not something like '1.0' or '01' (which will break the comparison). |
Modified by: @pcisarstatus: Resolved [ 5 ] => Closed [ 6 ] |
Submitted by: Pósa József (posaj)
Executing SELECT * FROM KIADT WHERE KIADF_SIF IN (SELECT SIF FROM TMPSYNC) command take 125 msec on 2.0.3 and 1 min 13 sec on 3.0.2.
The two databases are identical, with same data and indexes.
Firebird 2.0.3:
Plan
PLAN (TMPSYNC INDEX (RDB$PRIMARY94))
PLAN (KIADT NATURAL)
Adapted Plan
PLAN (TMPSYNC INDEX (INTEG_387))
PLAN (KIADT NATURAL)
------ Performance info ------
Prepare time = 15ms
Execute time = 125ms
Avg fetch time = 5,00 ms
Reads from disk to cache = 0
Writes from cache to disk = 0
Fetches from cache = 269 713
Firebird 3.0.2:
Plan
PLAN (TMPSYNC NATURAL)
PLAN (KIADT NATURAL)
------ Performance info ------
Prepare time = 15ms
Execute time = 1m 13s 828ms
Avg fetch time = 36 914,00 ms
Current memory = 1 189 906 648
Max memory = 1 218 517 920
Memory buffers = 50 000
Reads from disk to cache = 0
Writes from cache to disk = 0
Fetches from cache = 228 297 158
The text was updated successfully, but these errors were encountered: