# applying attributes on partitioned tables

**URL:** <https://forum.kx.com/t/applying-attributes-on-partitioned-tables/11409>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [December 1, 2016, 9:42am UTC](https://forum.kx.com/t/applying-attributes-on-partitioned-tables/11409 "2016-12-01T09:42:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hungry\_Goat1](https://avatars.discourse-cdn.com/v4/letter/h/d78d45/32.png) [@Hungry\_Goat1](https://forum.kx.com/u/Hungry_Goat1)\
**Post date:** [December 1, 2016, 9:42am UTC](https://forum.kx.com/t/applying-attributes-on-partitioned-tables/11409/1 "2016-12-01T09:42:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![charlie1](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@charlie1](https://forum.kx.com/u/charlie1)\
**Post date:** [December 1, 2016, 10:09am UTC](https://forum.kx.com/t/applying-attributes-on-partitioned-tables/11409/2 "2016-12-01T10:09:00Z")

</div>

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:`a`b`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 &nbsp; | t f a

----| -----

date| d &nbsp; &nbsp;

sym | s &nbsp; &nbsp;

time| t &nbsp; 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 `SYMBOL`TIMESTAMP in each partition. Then you can set the parted attribute on SYMBOL which should result in the most efficient access for this query.

&nbsp;

hth,

Charlie

---

<div class="post-metadata">

**Author:** ![Hungry\_Goat1](https://avatars.discourse-cdn.com/v4/letter/h/d78d45/32.png) [@Hungry\_Goat1](https://forum.kx.com/u/Hungry_Goat1)\
**Post date:** [December 1, 2016, 10:47am UTC](https://forum.kx.com/t/applying-attributes-on-partitioned-tables/11409/3 "2016-12-01T10:47:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![carfield11](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@carfield11](https://forum.kx.com/u/carfield11)\
**Post date:** [December 1, 2016, 2:50pm UTC](https://forum.kx.com/t/applying-attributes-on-partitioned-tables/11409/4 "2016-12-01T14:50:00Z")

</div>

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](http://code.kx.com/wiki/JB:KdbplusForMortals/splayed%5C_tables#1.2.4.2%5C_Sorting%5C_and%5C_Applying%5C_Attributes)
