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
Add possibility to honor explicitly stored plan without any try of modification [CORE5500] #5769
Comments
Commented by: @dyemanov Please specify also the query related to these plans. |
Commented by: @livius2 here is query - but ticket is for general solution SELECT |
Commented by: @dyemanov Do you have other cases? This one so far looks like a bug to be fixed. |
Commented by: @livius2 At this time have not to show you. But now i realize that better is to create ticket. |
Commented by: Sean Leyne (seanleyne) It seems that this case is really about have the engine follow the defined PLAN, since that is what the engine should be doing -- a PLAN statement is the instruction that tells the engine what indexes should be used/followed. No? |
Commented by: @livius2 I have another case - but i do not know if the reason is the same because View is affected SELECT * from ( UNION all UNION all UNION all UNION all UNION all plan is honored but when i create view CREATE VIEW VSENSOR3 (SENSOR_UID, NAZWA, ID, ID_SENSOR, DT, WARTOSC, FLAGS) plan is changed dramatically PLAN (SORT (JOIN (R S INDEX (PK_SENSOR), R SD INDEX (FK_SENSOR_DATA__SENSOR))), SORT (JOIN (R S INDEX (PK_SENSOR), R SD INDEX (FK_SENSOR_DATA__SENSOR))), SORT (JOIN (R S INDEX (PK_SENSOR), R SD INDEX (FK_SENSOR_DATA__SENSOR))), SORT (JOIN (R S INDEX (PK_SENSOR), R SD INDEX (FK_SENSOR_DATA__SENSOR))), SORT (JOIN (R S INDEX (PK_SENSOR), R SD INDEX (FK_SENSOR_DATA__SENSOR))), SORT (JOIN (R S INDEX (PK_SENSOR), R SD INDEX (FK_SENSOR_DATA__SENSOR))), SORT (JOIN (R S INDEX (PK_SENSOR), R SD INDEX (FK_SENSOR_DATA__SENSOR)))) i tested now and if i create stored procedure it honor plan but view not |
Commented by: @livius2 For above situation with view i can provide whole metadata if you need it |
Commented by: @dyemanov It's not expected to work for views. In theory, it could, but only for trivial "select ... from view". Any extra condition added, or any table joined, or whatever else, would make the plan unusable hence ignored. Embedding the plan inside the view (even if syntactically allowed) is a design mistake, you shouldn't go this route. |
Commented by: @livius2 Yes, i only use explicit plan in view for its main query only if i use it as But do you think that something like raising error will be better than changing explicitly stored plan? |
Commented by: @livius2 I have another sample SELECT Firebird change plan to |
Commented by: @livius2 statistics of indexes for above IXA_ZLEC_FAKT__NR_FAKT_KORYG 0.000024 0 NR_FAKT_KORYG 0.000024 |
Commented by: @dyemanov Are you sure index order makes any difference? |
Commented by: @livius2 I am not sure on Firebird |
Submitted by: @livius2
Please provide ability to tell Firebird "do not touch" explicitly stored plan
now we can store plan within query itself
SELECT
...
FROM
...
PLAN ...
ORDER BY ...
but this plan is sometimes adapted by engine and sometimes it do this "wrongly".
Will be good to have some way to prevent this action
I do not know if new "keyword" should be provided
Like "STRICT_PLAN" ...
sample when i store plan for query
PLAN SORT (JOIN (JOIN (JOIN (JOIN (JOIN (JOIN (RL INDEX (ROZLICZENIE_FK2,ROZLICZENIE_FK2,ROZLICZENIE_FK2,ROZLICZENIE_FK2,ROZLICZENIE_FK2), WP INDEX (WPLATA_PK)), U INDEX (UMOWA_PK)), RD INDEX (RODZAJ_DZIAL_PK)), DR INDEX (DOK_ROZLICZENIOWY_PK)), K INDEX (KONTRAHENT_PK)), W INDEX (WARUNKI_PK)))
engine change it to - and i have no way to prevent that change :(
PLAN SORT (JOIN (JOIN (JOIN (JOIN (JOIN (JOIN (RL NATURAL), WP INDEX (WPLATA_PK)), U INDEX (UMOWA_PK)), RD INDEX (RODZAJ_DZIAL_PK)), DR INDEX (DOK_ROZLICZENIOWY_PK)), K INDEX (KONTRAHENT_PK)), W INDEX (WARUNKI_PK)))
The text was updated successfully, but these errors were encountered: