I have a huge dataset around 20million, I want to ...
# general
p
I have a huge dataset around 20million, I want to do an order by which some revenue column, however order by takes time, is there anyway order by can be effective or fast?
j
Hi Pratush, If you actually want to sort and return 20 million records from a query, that sounds more like a report, and that is not Druid's areas of focus. If, however, you are sorting so that you can retrieve the Top N elements, Druid does have features which should be able to do this fairly performantly. Can you post an example query, and let us know what type of response time you are expecting? Thanks. John
p
sample query : select a,b,c,d, sum(value) from table group by a,b,c,d order by sum(value) desc limit 100 @John Kowtko
j
Okay, can you do an explain query plan and show the native query?
p
{ "queryType": "groupBy", "dataSource": { "type": "table", "name": "table_name" }, "intervals": { "type": "intervals", "intervals": [ "2020-01-31T000000.000Z/2024-06-30T000000.001Z" ] }, "granularity": { "type": "all" }, "dimensions": [ { "type": "default", "dimension": "a", "outputName": "d0", "outputType": "STRING" }, { "type": "default", "dimension": "b", "outputName": "d1", "outputType": "STRING" }, { "type": "default", "dimension": "c", "outputName": "d2", "outputType": "STRING" }, { "type": "default", "dimension": "d", "outputName": "d3", "outputType": "STRING" } ], "aggregations": [ { "type": "doubleSum", "name": "a0", "fieldName": "value" } ], "postAggregations": [ { "type": "expression", "name": "s0", "expression": "round((\"a0\" / 1000000),2)", "outputType": "DOUBLE" }, { "type": "expression", "name": "s1", "expression": "round(\"a1\",2)", "outputType": "DOUBLE" } ], "having": { "type": "filter", "filter": { "type": "range", "column": "a0", "matchValueType": "DOUBLE", "lower": 100, "upper": 200 }, "finalize": true }, "limitSpec": { "type": "default", "columns": [ { "dimension": "a0", "direction": "descending", "dimensionOrder": { "type": "numeric" } } ], "limit": 25 }, "context": { "queryId": "xyz, "sqlOuterLimit": 1001, "sqlQueryId": "abcd", "sqlStringifyArrays": false, "useNativeQueryExplain": true } } @John Kowtko