[Solved] How to represent a JDE hierarchical fetch in UML Sequence Diagram?
Looking to automatically optimize YOUR SQL query? Start for free.

EverSQL Database Performance Knowledge Base

How to represent a JDE hierarchical fetch in UML Sequence Diagram?

I'm trying to represent in a UML diagram the following:

enter image description here

What I'm trying to explain with the diagram is that the program will do a fetch in the table using three variables: col1val, col2val and col3val; & then it will return variable col4val.

However, this is supposed to be a hierarchical fetch (not sure about the terminology), which means that it should first look up for all the columns at the same time:

SELECT col4 FROM Table WHERE col1 = col1val AND col2 = col2val AND col3 = col3val;

If it's successful, the program should leave the section and stop fetching. However, if the program fails to do the fetch, then it will try again, but adding the condition col1val IS NULL.

SELECT col4 FROM Table WHERE col1 IS NULL AND col2 = col2val AND col3 = col3val;

Like that as many times and fields as possible. If the program ends up finding nothing after the last iteration, we now retrieve error message.

From the diagram, the first thing I would like to avoid is to repeat:

enter image description here

Because it is exactly the same in all instances. I'm only nullifying fields.

I explored the option of building an IFs "pyramid", but I need to adjust the diagram with certain frequency, so repositioning the alt/if section every time takes too much.

How to optimize this SQL query?

The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:

  1. Description of the steps you can take to speed up the query.
  2. The optimal indexes for this query, which you can copy and create in your database.
  3. An automatically re-written query you can copy and execute in your database.
The optimization process and recommendations:
  1. Create Optimal Indexes (modified query below): The recommended indexes are an integral part of this optimization effort and should be created before testing the execution duration of the optimized query.
Optimal indexes for this query:
ALTER TABLE `Table` ADD INDEX `table_idx_col1_col1v_col2_col2v_col3_col3v` (`col1`,`col1val`,`col2`,`col2val`,`col3`,`col3val`);
The optimized query:
        Table.col1 = Table.col1val 
        AND Table.col2 = Table.col2val 
        AND Table.col3 = Table.col3val

Related Articles

* original question posted on StackOverflow here.