Entries in .Q.pn (2)

How do I expose a subset of partitions and remove the rest from view?

Short answer: .Q.view partition_list

By default, all partitions of a given historical kdb database are available. The .Q.view function enables a given kdb process instance to selectively expose an arbitrary set of partitions into view.

The following example restricts all operations of the database instance to the most recent partition date (typically the previous business day):

q)yesterday: last date
q).Q.view yesterday
q)count date
1
q)yesterday ~ value exec from select distinct date from trade
1b
q)

Here is a more realistic example of a date partitioned historical database where viewable partitions are limited to those year-to-date:

q)start_date: "D" $ string[`year $ .z.D], ".01.01"
q)end_date: last date
q).Q.view date where date within (start_date; end_date)
q)count select from trade where not date within (start_date;
end_date)
0
q)

See also: .Q.pn

What happens if I duplicate a partition name across multiple segments?

The content of the table is split across n segments. For example, par.txt specifies 3 segments below and slices a table named vltablename by symbol into 3 segments.

For example:

$ cat /vol/db/par.txt
/vol/disk1/segment
/vol/disk2/segment
/vol/disk3/segment

$ ls /vol/disk*/segment/2011.03.07/vltable
/vol/disk1/segment/2011.03.07/vltable # sym A-I
/vol/disk2/segment/2011.03.07/vltable # sym J-R
/vol/disk3/segment/2011.03.07/vltable # sym R-Z

Note that the typical `p# attribute of column sym will be missing in the query result. Remember to re-apply the attribute prior to use.

See also: .Q.u, and .Q.par