DolphinDB: Is there a quick way to query the data of a specified date?

29 Views Asked by At

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
1

There are 1 best solutions below

0
Claire mcc On

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 condition where Date == date is always True and the script always returns the records of “StockCode“ for all dates, instead of on a specified date.