Skip to main content
irshadsheikm
December 8, 2023
Question

Appian Dual Sorting

  • December 8, 2023
  • 5 replies
  • 0 views

Hi Team,

We are facing an issue when we try to fetch the data through a query entity with a specified column sorting. When we execute the expression we specify the column on which sorting needs to happen. But when we get the result back we see two sorting columns in the result set.

Is there any reason that might cause this? This is causing us perfomance issues

    5 replies

    mikes0011
    Brainy
    December 8, 2023

    Why would you think this is "causing performance issues"?  AFAIK a secondary sort on the primary key ID would not add anything more than trivial extra burden to the query, if that.

    In any case I'm guessing this relates to the Documented Feature Evolution released in Appian 22.3 wherein the queryEntity behavior was changed to "fix an incorrect sorting behavior so that a sort is now automatically applied on the primary key field when there is no other sort applied" (and i assume this might mean that it's been added as a secondary sort in other circumstances, such as sorting on other non-unique fields, so that sorts on returned queries avoid an erratic behavior where different queries are returned in different orders for no apparent reason).

    victorb0532
    June 24, 2025

    Hello,

    We observed a similar behavior in our project. On a table with a large number of rows (20,000,000 rows), performing a multi-column sort including the primary key caused the index that was supposed to be used to be considered irrelevant by the DBMS (Oracle). We had to create a composite index, including the desired column and the primary key, in order for it to be used.

    piyushv626427
    February 5, 2026

     [mention:f5f3a9f239bd43f0b95747faeb03193a:e9ed411860ed4f2ba0265705b8793d05] [mention:b45a4f6a20b14a008e4e0ec732a8bf98:e9ed411860ed4f2ba0265705b8793d05] [mention:d0c03bdc2af241ba80e94a8960154029:e9ed411860ed4f2ba0265705b8793d05] 

    I m having a similar kind of issue, where in query entity, i have applied sorting on one field but its showing error with orderby: sort with 2 fields. So i m unable to find the exact root cause for this error. We are using appian 24.2 version. 

    mikes0011
    Brainy
    February 5, 2026

    I'm not sure it's an "error" still, I believe it simply has to do with using a sort column that is not unique - thus the PKID is automatically included to introduce some consistent sorting order, because otherwise different query executions would return apparently-different sorts when sorting by a column where multiple rows can have the same value (i believe this behavior was observed in the past and people complained about it, so this behavior was introduced as a way to fix it).  I stand behind my belief that it's unlikely to ever cause noticeable performance issues, even in heavy queries.