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
Problem with using a computed index on a computed column #7945
Comments
Apart from fixing this bug, is there any workaround for this? It's quite important in our case due to the new law starting soon. |
Do you need more informations to reproduce the problem? |
Reproducible test case, please |
So far I'm unable to give you the exact steps to reproduce the problem, but maybe the info below will tell you something. ALTER TABLE TEST_INDEKS ADD CONSTRAINT PK_TEST_INDEKS PRIMARY KEY (ID_TEST_INDEKS); I insert random data: |
Could you try with two tables and LEFT JOIN as in original case ? |
This is not needed. Those are minimum steps needed to reproduce. On the original table I reproduce this every time. |
Then there should be possible to extract this table DDL only and reproduce the issue. |
Unfortunately, when I created another table with DDL from the old one (I had to get rid of columns being selects from other tables and all foreign keys), I'm still unable to reproduce the problem. |
Is it reproducible with metadata-only DB ? |
Yes, it is. I will prepare it and send it to you. |
TEST_INDEX.zip |
It requires UDF |
Here are all udf dll files |
Reproduced, investigating |
In short: relation have a lot of computed fields, most of them are trivial, but some depends on stored procedures that in turn depend on the same relation. When relation metadata is loaded for a very first time, this dependency circle makes some computed fields to incorrectly compute its expression, as not all computed fields have its expressions loaded at this moment. When index is creating, engine sees already loaded table's metadata, thus index get correct expression and works (until disconnect). |
Hello.
Firebird 3.0.11 Windows 64 and Linux.
In a session I create an index on a computed field.
Table NAGL, we have column DO_KSEF and DO_KSEFX. Both are computed fields, I create an index on DO_KSEFX.
INTEGER
COMPUTED BY (CASE WHEN (DO_KSEF = 1) THEN ID_NAGL ELSE -ID_NAGL END) (ID_NAGL is the primary key)
CREATE INDEX MK_DO_KSEFX ON NAGL COMPUTED BY (DO_KSEFX);
After this, I run query:
select first 1 1
from NAGL N
left outer join NAGLKSEF NK on (N.ID_NAGL = NK.ID_NAGL) and
(NK.SRODOWISKO = 1)
where N.DO_KSEFX > 0 and coalesce(NK.POSTEPX, 0) < 3
I get plan:
PLAN JOIN (N INDEX (MK_DO_KSEFX), NK INDEX (FK_NAGLKSEF_NAGL))
However, I reconnect, rerun this query and get unindexed reads from NAGL:
PLAN JOIN (N NATURAL, NK INDEX (FK_NAGLKSEF_NAGL))
This cause signifant delay.
When I want to force the use of the previous plan, I get an error:
index MK_DO_KSEFX cannot be used in the specified plan.
Why? It looks like a bug.
The text was updated successfully, but these errors were encountered: