# varchar in splay columns

**URL:** <https://forum.kx.com/t/varchar-in-splay-columns/11531>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [April 29, 2017, 2:19am UTC](https://forum.kx.com/t/varchar-in-splay-columns/11531 "2017-04-29T02:19:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![david\_bieber](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@david\_bieber](https://forum.kx.com/u/david_bieber)\
**Post date:** [April 29, 2017, 2:19am UTC](https://forum.kx.com/t/varchar-in-splay-columns/11531/1 "2017-04-29T02:19:00Z")

</div>

Hi All,

I have a large files of around 500mb with around 25 columns which have a imported into KDB.

The file contains a mixture of symbols, varchar and integers in the table which I call tX

For instance a subset of the meta data I import looks like this

`meta tXc t f aid sti ip fstr1 Cstr2 Cstr3 Cstr4 Cstr5 C`

I want to store this file as a splay so

1. can create a empty splay table

`empty tablesX: ([] id:`symbol$(); ti:`int$() ; p:`float$(); str1:(); str2(); str3(); str4(); str5())`

or

`table with nullssX: ([] id:enlist `; ti:enlist 0Ni ; p:enlist 0n; str1:enlist “None”; str2: enlist “None” str3: enlist “None”; str4: enlist “None”; str5: “None”)`

1. enumerate and create a splay sX

`sX: .Q.en[`:c:/test] sX`:c:/test/sX/ set sX`

1. and upsert the table tX

`tX: .Q.en[`:c:/test] tX`:c:/test/sX/ upsert tX`

For the empty sX table (the first one) kdb hangs but for the null sX table (the second one) it works and splays the table as expected.

However if I now type  
`meta sX`  
it takes more that 60s to calculate. In fact any calculation is very slow on this splay table. However the calculation on tX (the imported table) is fast. In addition if I cast everything to symbols and then splay the table, the calculations is fast.

I have been trying to replicate this error in a small piece of code without success. It seems to be specific the the table I am loading. Does anyone have any ideas or suggestions of where I am going wrong. I am completely at a loss…

Could there be special characters that are not allowed in varchar?

Is there a limit on the number of varchar columns?

Any advice would be greatly appreciated.

Thanks

David

---

<div class="post-metadata">

**Author:** ![trentkg](https://avatars.discourse-cdn.com/v4/letter/t/4af34b/32.png) [@trentkg](https://forum.kx.com/u/trentkg)\
**Post date:** [May 1, 2017, 3:18pm UTC](https://forum.kx.com/t/varchar-in-splay-columns/11531/2 "2017-05-01T15:18:00Z")

</div>

For splayed tables there are very strict type requirements. You cannot have 0h lists in your tables.&nbsp;

run&nbsp;

distinct type’'[sX]

on your table (when it is populated) and ensure that no types are 0h.&nbsp;

Splaying is also an optimisation, that may come with some overhead. It would not surprise me if your table is not large enough to utilize the speedup of this optimisation.&nbsp;

---

<div class="post-metadata">

**Author:** ![david\_bieber](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@david\_bieber](https://forum.kx.com/u/david_bieber)\
**Post date:** [May 2, 2017, 1:27pm UTC](https://forum.kx.com/t/varchar-in-splay-columns/11531/3 "2017-05-02T13:27:00Z")

</div>

Hi KDB Group,&nbsp;

I have found out that if you cast varchar columns to symbols the time required to calculate “meta” of the splay decreases.&nbsp;  
However I still not not understand the relationship between the number of varchar columns in a splay table and the impact on performance. Any insights would be appreciated.

David
