Issue Details (XML | Word | Printable)

Key: DERBY-781
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: A B
Reporter: Satheesh Bandaram
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Materialize subqueries in select list where possible to avoid creating invariant resultsets many times.

Created: 23/Dec/05 12:15 PM   Updated: 30/Jun/09 04:12 PM
Return to search
Component/s: SQL
Affects Version/s: 10.1.1.0, 10.2.1.6
Fix Version/s: 10.2.1.6

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works d781_v1.patch 2006-07-01 08:55 PM A B 89 kB
File Licensed for inclusion in ASF works d781_v1.stat 2006-07-01 08:55 PM A B 0.9 kB
Text File Licensed for inclusion in ASF works d781_v2.patch 2006-07-12 10:37 PM A B 76 kB
HTML File Licensed for inclusion in ASF works DERBY-781_v1.html 2006-07-01 08:55 PM A B 91 kB
Environment: generic

Issue & fix info: Release Note Needed
Resolution Date: 19/Sep/06 03:34 PM


 Description  « Hide
Derby's handling of union subqueries in from list can be improved by materializing invariant resultsets once, rather than creating them many times.

For example:

create view V1 as select i, j from T1 union select i,j from T2;
create view V2 as select a,b from T3 union select a,b from T4;
insert into T1 values (1,1), (2,2), (3,3), (4,4), (5,5);

For a query like select * from V1, V2 where V1.j = V2.b and V1.i in (1,2,3,4,5), it is possible the resultset for V2 is created 5 times. (assuming V2 is choosen as the the inner table) This can be very costly if the underlying selects can take long time and also may perform union many times.

Enhance materialization logic in setOperatorNode.java. It currently returns FALSE always.

public boolean performMaterialization(JBitSet outerTables)
throws StandardException
{
// RESOLVE - just say no to materialization right now - should be a cost based decision
return false;

/* Actual materialization, if appropriate, will be placed by our parent PRN.
* This is because PRN might have a join condition to apply. (Materialization
* can only occur before that.
*/
//return true;
}

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
No work has yet been logged on this issue.