xiaokang opened a new pull request, #10694:
URL: https://github.com/apache/doris/pull/10694

   # Proposed changes
   
   Issue Number: close #10646
   
   ## Problem Summary:
   
   Describe the overview of changes.
   
   BE part for https://github.com/apache/doris/issues/10646. The FE part is 
https://github.com/apache/doris/pull/10647.
   
   There is a common query pattern to find latest time serials data.
    eg. SELECT * from t_log WHERE t>t1 AND t<t2 ORDER BY t DESC LIMIT 100
   
   If the ORDER BY columns is the prefix of the sort key of table, it can
   be greatly optimized to read much fewer data instead of read all data
   between t1 and t2.
   
   By leveraging the same order of ORDER BY columns and sort key of table,
   just read the LIMIT N rows for each related segment and merge N rows.
   
   1. set read_orderby_key to true for read_params and _reader_context
      if olap_scan_node's sort info is set.
   2. set read_orderby_key_reverse to true for read_params and _reader_context
      if is_asc_order is false.
   3. rowset reader force merge read segments if read_orderby_key is true.
   4. block reader and tablet reader force merge read rowsets if 
read_orderby_key is true.
   
   5. for ORDER BY DESC, read and compare in reverse order
   5.1 segment iterator read backward using a new BackwardBitmapRangeIterator 
and
       reverse the result block before return to caller.
   5.2 VCollectIterator::LevelIteratorComparator, VMergeIteratorContext return
       opposite result for _is_reverse order in its compare function.
   
   
   ## Checklist(Required)
   
   1. Does it affect the original behavior: (No)
   2. Has unit tests been added: (No)
   3. Has document been added or modified: (No Need)
   4. Does it need to update dependencies: (No)
   5. Are there any changes that cannot be rolled back: (No)
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at 
[d...@doris.apache.org](mailto:d...@doris.apache.org) by explaining why you 
chose the solution you did and what alternatives you considered, etc...
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to