applying attributes on partitioned tables

I have an partitioned table with 40 columns.

q)meta md

c | t f a

----------| -----

date | d

TIMESTAMP | t

SYMBOL | s

BID | f

ASK | f

BIDSIZE | f

ASKSIZE | f

..


Any query like “select TIMESTAMP, BID, ASK from md where date = 2015.11.20, sym = `XYZ” takes a few seconds to respond.


Is there any way to make the query faster? I tried applying the sorted attribute on the TIMESTAMP column but unfortunately I am getting `par error.


Thanks

You’re probably trying

q)update s#TIMESTAMP from md

'par

where as you need to set the sort attr for the column in each partition more explicitly, e.g.

q):db/2000.01.01/t/ set .Q.en[:db](sym:ab`c;time:.z.t+til 3);

q)\l db

q)update s#time from t / the error you observe

'par

q){@[hsym`$x,“/t”;`time;`s#]} each string date;

q)meta t

c   | t f a

----| -----

date| d    

sym | s    

time| t   s

however, having a sorted attr on TIMESTAMP won’t help your query.

Your query would benefit enormously from having the table md sorted by SYMBOLTIMESTAMP in each partition. Then you can set the parted attribute on SYMBOL which should result in the most efficient access for this query.

 

hth,

Charlie

Thanks Charles. I understand it now. Is there a way to make the table parted by SYMBOL, TIMESTAMP.

Hi Hungry, you can take a look this http://code.kx.com/wiki/JB:KdbplusForMortals/splayed\_tables#1.2.4.2\_Sorting\_and\_Applying\_Attributes