All,

There are some kinds of queries that have data access methods linked to 
each other. Windowed functions are the obvious example, but it happens 
even for regular aggregate functions. For example, COUNT(DISTINCT) needs 
not only read the underlying stream but also sort it in order to 
eliminate duplicates. So we have both retrieval and sorting inside the 
aggregation node and sorting is based on the retrieval:

select count(distinct rdb$relation_id)
from rdb$relations
group by rdb$relation_name

Select Expression
   -> Aggregate
     -> Table "RDB$RELATIONS" Access By ID
       -> Index "RDB$INDEX_0" Scan
     /*
     -> Sort (unique)
       -> Table "RDB$RELATIONS" Access By ID
          -> Index "RDB$INDEX_0" Scan
     */

However, I'd like to skip the repeating part and replace it with a 
reference to the earier introduced part, because technically there's 
only one retrieval, not two.

The possible options are:

(A)

Select Expression
   -> Aggregate
     -> Table "RDB$RELATIONS" Access By ID
       -> Index "RDB$INDEX_0" Scan
     -> Sort (unique)

where no input for sorting means the prior stream

(B)

Select Expression
   -> Aggregate
     -> Table "RDB$RELATIONS" Access By ID
       -> Index "RDB$INDEX_0" Scan
     -> Sort (unique)
       -> ^^^

which means to look above for the input stream. But the indentation 
makes it hard to understand what exactly we refer to. And theoretically 
there maybe references to farther parts of the plan, not only the 
neighbours.

(C)

Select Expression
   -> Aggregate
     -> Table "RDB$RELATIONS" Access By ID
       -> Index "RDB$INDEX_0" Scan
     -> Sort (unique)
       -> $base$

some keyword is used to refer to the input stream of the aggregation

(D)

Select Expression
   -> Aggregate
     -> 1: Table "RDB$RELATIONS" Access By ID
       -> Index "RDB$INDEX_0" Scan
     -> 2: Sort (unique)
       -> $(1)

all non-trivial methods have their children enumerated so they can be 
referenced by numbers. But for complex queries there will be multiple 
(1)s and (2)s making it harder to match the proper one.

(E)

Select Expression
   -> 1: Aggregate
     -> 2: Table "RDB$RELATIONS" Access By ID
       -> 3: Index "RDB$INDEX_0" Scan
     -> 4: Sort (unique)
       -> $(2)

or

Select Expression
1:  -> Aggregate
2:    -> Table "RDB$RELATIONS" Access By ID
3:      -> Index "RDB$INDEX_0" Scan
4:    -> Sort (unique)
5:      -> $(2)

all methods are globally enumerated. The output is a bit noisy, but 
personally I favor (E)#2 so far.

Comments anyone? Other suggestions?


Dmitry

------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to