-
-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
bad plan joining view including union [CORE4049] #1476
Comments
Commented by: Attila Molnár (e_pluribus_unum) create view missed |
Modified by: Attila Molnár (e_pluribus_unum)description: Hi! CREATE TABLE a (id INTEGER PRIMARY KEY, code VARCHAR (10) UNIQUE, name VARCHAR (10)); SELECT * This has the following plan now : This is wrong. It shold be (same as the select with left join) : Index statistics ha no effect at all, the plan is always wrong. Thank You! => Hi! CREATE TABLE a (id INTEGER PRIMARY KEY, code VARCHAR (10) UNIQUE, name VARCHAR (10)); CREATE VIEW v ( SELECT * This has the following plan now : This is wrong. It shold be (same as the select with left join) : Index statistics ha no effect at all, the plan is always wrong. Thank You! |
Modified by: Attila Molnár (e_pluribus_unum)description: Hi! CREATE TABLE a (id INTEGER PRIMARY KEY, code VARCHAR (10) UNIQUE, name VARCHAR (10)); CREATE VIEW v ( SELECT * This has the following plan now : This is wrong. It shold be (same as the select with left join) : Index statistics ha no effect at all, the plan is always wrong. Thank You! => Hi! CREATE TABLE a (id INTEGER PRIMARY KEY, code VARCHAR (10) UNIQUE, name VARCHAR (10)); CREATE VIEW v ( SELECT * This has the following plan now : This is wrong. It shold be (same as the select with left join) : Index statistics ha no effect at all, the plan is always wrong. Thank You! |
Modified by: Attila Molnár (e_pluribus_unum)description: Hi! CREATE TABLE a (id INTEGER PRIMARY KEY, code VARCHAR (10) UNIQUE, name VARCHAR (10)); CREATE VIEW v ( SELECT * This has the following plan now : This is wrong. It shold be (same as the select with left join) : Index statistics ha no effect at all, the plan is always wrong. Thank You! => Hi! CREATE TABLE a (id INTEGER PRIMARY KEY, code VARCHAR (10) UNIQUE, name VARCHAR (10)); CREATE VIEW v ( SELECT * This has the following plan now : This is wrong. It shold be (same as the select with left join) : Index statistics ha no effect at all, the plan is always wrong. Thank You! |
Commented by: @dyemanov FWIW, unions are always optimized as the leading stream, i.e the first one in the join order (unless it's an outer join). It affects what indices could be used for the underlying tables. Unfortunately, it cannot be fixed easily. Maybe in FB3, but no guarantees yet. For the time being, use a left join as a workaround. |
Modified by: @dyemanovassignee: Dmitry Yemanov [ dimitr ] |
Modified by: @dyemanovVersion: 2.1.5 [ 10420 ] Version: 2.5.1 [ 10333 ] Version: 2.1.4 [ 10361 ] Version: 2.5.0 [ 10221 ] Version: 2.0.6 [ 10303 ] Version: 3.0 Initial [ 10301 ] Version: 2.1.3 [ 10302 ] Version: 2.1.2 [ 10270 ] Version: 2.0.5 [ 10222 ] Version: 2.1.1 [ 10223 ] Version: 2.1.0 [ 10041 ] |
Commented by: Valdir Stiebe Junior (ogecrom) I've got the same results in a inner join with a view on a TABLE inner join VIEW case (without union inside the view). The inner join plan use NATURAL while the left join plan use the corrects indexes. |
This is still an issue (Tested with FB30 and FB40) |
Submitted by: Attila Molnár (e_pluribus_unum)
Relate to CORE4976
Votes: 3
Hi!
CREATE TABLE a (id INTEGER PRIMARY KEY, code VARCHAR (10) UNIQUE, name VARCHAR (10));
CREATE TABLE b (id INTEGER PRIMARY KEY, code VARCHAR (10) UNIQUE, name VARCHAR (10));
CREATE TABLE c (id INTEGER PRIMARY KEY, code VARCHAR (10) UNIQUE, name VARCHAR (10));
CREATE VIEW v (
id,
code,
name)
AS
SELECT
id, code, name
FROM a
UNION
SELECT
id, code, name
FROM b
SELECT *
FROM c
JOIN v ON v.code = c.code
WHERE c.id=0
This has the following plan now :
PLAN JOIN ((V A NATURAL)
PLAN (V B NATURAL), C INDEX (RDB$8))
This is wrong. It shold be (same as the select with left join) :
PLAN JOIN (C INDEX (RDB$PRIMARY7)(V A INDEX (RDB$2))
PLAN (V B INDEX (RDB$4)))
Index statistics ha no effect at all, the plan is always wrong.
Thank You!
The text was updated successfully, but these errors were encountered: