I create a DFS table of stock data partitioned by columns “Date“ and “StockCode“ and specify a hash function in the parameter sortKeyMappingFunction to limit the number of sort keys in each partition to no more than 1,000. I want to query all records of “StockCode” on a specified date, but it takes me a long time for a full table scan. Is there a quick way to achieve this in DolphinDB?
I use the TSDB storage engine and set the parameter keepDuplicates to ALL:
engine: TSDB, keepduplicates: all
The following is my script for the query:
select distinct(StockCode) from loadTable("dfs://stock_history", "depthBook") where Date == date order by distinct_StockCode
In the conditional statement
where Date == date, though “date“ is a date scalar, “Date“ and “date“ are interpreted as the same since table columns in DolphinDB are case-insensitive. Therefore, the filtering conditionwhere Date == dateis always True and the script always returns the records of “StockCode“ for all dates, instead of on a specified date.