Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this article, we will be using a custom query with JOIN statement (to get derived data set) to build the data set for the Datalist. The custom query will be placed in JDBC Datalist Database Binder.

The article's discussion and result is produced using MySQL 5.6 but should also be applicable to all RDBMS attached to Joget Workflow.

Let's set the stage first.

...

Depending on which Userview Menu you use, most of them would provide you the capability to show the row count appended to the menu name. The query we have here would take a long time to compute because the database would need to first execute the query (with JOIN) and return the data set entirely before it is able to count the records. The count query will be something like...as the following:-

Code Block
languagesql
titleCount Query
SELECT COUNT(*) FROM (SELECT o.*, i.* FROM order o JOIN order_item i ON o.id = i.order_id) temp

Retrieving derived data and then getting the row count will take anywhere from few seconds to few minutes to load depending on the actual row size and database performance.

This is the explain query result just in case if you are more inclined towards RDBMS kind of explanations.

idselect_typetabletypepossible_keyskeykey_lenrefrowsExtra
1PRIMARY<derived2>ALL    2000000 
2DERIVEDiALLIndex 2   2000000Using where
2DERIVEDoeq_refPRIMARYPRIMARY767i.order_id1 

As you can see, there are 2 ALL type in retrieving the result. The definition of ALL type is as follow.

 

Info
titleALL

A full table scan is done for each combination of rows from the previous tables. This is normally not good if the table is the first table not marked const, and usually very bad in all other cases. Normally, you can avoid ALL by adding indexes that enable row retrieval from the table based on constant values or column values from earlier tables. (Source)

 

Viewing a List in a Userview

...