4 ms·
I guess it depends on the join predicate. For a vanilla equi-join, no grouping is required. Let's say we have the following two tables and a view that joins th
by branko_d 6y ago
I guess it depends on the join predicate. For a vanilla equi-join, no grouping is required.
Let's say we have the following two tables and a view that joins them:
CREATE TABLE PARENT (
PARENT_ID int PRIMARY KEY,
PARENT_NAME varchar(255)
);
CREATE TABLE CHILD (
CHILD_ID int PRIMARY KEY REFERENCES PARENT,
CHILD_NAME varchar(255)
);
CREATE VIEW PARENT_CHILD
AS
SELECT
*
FROM
PARENT
JOIN CHILD
ON PARENT_ID = CHILD_ID;
Now if you select any fields from PARENT, the query plan will physically access both PARENT and CHILD. For example:
SELECT
*
FROM
PARENT_CHILD;
SELECT
PARENT_ID,
PARENT_NAME
FROM
PARENT_CHILD;
But the following would physically access only CHILD (because it knows that for any existing CHILD row, the corresponding PARENT row must also exist):
SELECT
CHILD_ID,
CHILD_NAME
FROM
PARENT_CHILD;
- reshlo 6y agoWhat I’m suggesting is that the following still has to access CHILD despite only projecting columns from PARENT. If I understand it correctly, not projecting any columns from a joined table doesn’t mean it won’t be accessed, even for vanilla equi-joins. SELECT PARENT_ID FROM PARENT_CHILD;