Questions about Querying Data from an RDBMS

with Reference to this below URL,
forum.appian.com/.../Querying_Data_From_an_RDBMS.html
There are some doubts out of my interest.
Lets consider a scenario, like we have a view which is having 100k of data and it is trying to fetch the data with pagination with 25 records per page. we are using Query rules and we are in version 7.4
Knowing that pagination is given it will load only 25 records per page but our doubt is since pagination is used in the expression rule of displaying the data in grid,
1.Is Query Rule fetching all the records and showing 25 per page or is it hitting the db for the next 25 records,
2.Is this the same way how Query Entity works or is it different.
3.Knowing that the maximum limit of data for Query rule is 1 MB, is it the same for Query Entity or does this differ.
4.How does the performance of Query rule and Query Entity differ if the working of both are same.
Please Sugges...

OriginalPostID-196692

OriginalPostID-196692

  Discussion posts and replies are publicly visible

Parents
  • I've done a bit of testing on this and the results are quite interesting.

    Attached is a file containing the SQL generated for a query that gets all entries for a specific data entity, using paging info with a start index of 1, a batch size of 5 and a sort on ID ascending. The first set of SQL is that generated for a Query Rule, and the second is that generated for a Query Entity.

    In this instance, the Query Rule method generates one extra SQL statement than the Query Entity - 3 statements vs 2. It seems that the Query Rule first obtains a count, then gets the primary keys that it's going to retrieve, then finally selects the data using those keys. The Query Entity does exactly the same query to retrieve the count, but then gets the data and applies the limit in a single statement.

    There is, of course, arguably a performance benefit in not doing the second statement, but in this instance it would appear to be negligible; running the second statement directly in MySQL Workbench shows a query time of 0.000 seconds, so there's not even a millisecond of performance increase on the SQL side for this example.

    In my opinion the performance benefits displayed don't justify the significantly longer development time required for a Query Entity method - but maybe there are limitations sitting above the MySQL level that cause further delays.

    For me, the main observation from this testing is that the Query Rule applies the LIMIT 5; filter in (almost) exactly the same way as Query Entity, and so does not return all the data as suggested above.

    Obviously my example is a simple one, but I think it evidences that the differences between the two methods aren't that great for this case. No doubt Appian will be able to provide some more detailed analysis; it would be good to know how complex a query needs to be occurring to realise the potential performance benefits.

    QR_vs_QE.sql

Reply
  • I've done a bit of testing on this and the results are quite interesting.

    Attached is a file containing the SQL generated for a query that gets all entries for a specific data entity, using paging info with a start index of 1, a batch size of 5 and a sort on ID ascending. The first set of SQL is that generated for a Query Rule, and the second is that generated for a Query Entity.

    In this instance, the Query Rule method generates one extra SQL statement than the Query Entity - 3 statements vs 2. It seems that the Query Rule first obtains a count, then gets the primary keys that it's going to retrieve, then finally selects the data using those keys. The Query Entity does exactly the same query to retrieve the count, but then gets the data and applies the limit in a single statement.

    There is, of course, arguably a performance benefit in not doing the second statement, but in this instance it would appear to be negligible; running the second statement directly in MySQL Workbench shows a query time of 0.000 seconds, so there's not even a millisecond of performance increase on the SQL side for this example.

    In my opinion the performance benefits displayed don't justify the significantly longer development time required for a Query Entity method - but maybe there are limitations sitting above the MySQL level that cause further delays.

    For me, the main observation from this testing is that the Query Rule applies the LIMIT 5; filter in (almost) exactly the same way as Query Entity, and so does not return all the data as suggested above.

    Obviously my example is a simple one, but I think it evidences that the differences between the two methods aren't that great for this case. No doubt Appian will be able to provide some more detailed analysis; it would be good to know how complex a query needs to be occurring to realise the potential performance benefits.

    QR_vs_QE.sql

Children
No Data