TSInfo function
The TSInfo function returns information about a time series and the storage that is used by the time series.
Syntax
TSInfo(ts TimeSeries,
control BSON default NULL,
begin_tstamp DATETIME YEAR TO FRACTION(5) default NULL,
end_tstamp DATETIME YEAR TO FRACTION(5) default NULL)
returns BSON;
Syntax of control
{ { | smallElementPage: { Boolean <smallElementPage Options> } | largeElementPage: { Boolean <largeElementPage Options> } | element: { Boolean <element Options> } | containerPageSize:Boolean | btreeLeafSlotSize:Boolean | baseTableSize:Boolean | totalIntervalCount:Boolean | intervalCount: { Boolean <intervalCount Options> } | metadata: { Boolean <metadata Options> } | totalPages:Boolean | totalUserSlots:Boolean | totalSlots:Boolean | totalUserSize:Boolean | totalSize:Boolean | totalFree:Boolean | pageSizeDistribution:Boolean | memoryUsage: { Boolean <memoryUsage Options> } | compressionBuffer : { Boolean <compressionBuffer Options> } | compressionSessionStats : { Boolean <compressionSessionStats Options> } | rollingWindows: { Boolean <rollingWindows Options> } } }- ts
- The name of the TimeSeries column.
- control
- A BSON document that describes which values to return and the corresponding structure of the
output document. Each field can have a Boolean value of
true
orfalse
. Some fields can have subdocuments that refine the return value. Output values are in integers, unless otherwise indicated. The default document for the control parameter sets all values totrue
except for dormant rolling window containers:{ smallElementPage:true, largeElementPage:true, element:true, containerPageSize:true, btreeLeafSlotSize:true, baseTableSize:true, totalIntervalCount:true, intervalCount:true, metadata:true, totalPages:true, totalUserSlots:true, totalSlots:true, totalUserSize:true, totalSize:true, totalFree:true, pageSizeDistribution:true, memoryUsage:true, compressionBuffer:true compressionSessionStats:true rollingWindows:{active:true,dormant:false} }
- smallElementPage
- Information about pages that contain elements that are small enough to fit on one page.
- largeElementPage
- Information about pages that contain elements that are too large to fit on one page.
- element
- Information about the number of physical elements.
- containerPageSize
- The page size, in bytes, of containers. For example, 2048 or 4096.
- btreeLeafSlotSize
- The size, in bytes, of B-tree leaf slots that are used by the index on time series data.
- baseTableSize
- The size, in bytes, of the base table that contains the time series. Includes the size of any in-row time series data.
- totalIntervalCount
- The total number of partitions in rolling window containers. This value is not affected by the begin_stamp and end_stamp parameters or the setting of the rollingWindows field.
- intervalCount
- The number of active and dormant partitions in rolling window containers.
- metadata
- Information about the properties of the time series.
- totalPages
- The total number of element pages that are used by the time series. Equivalent to the number of small element pages plus the number of large element pages.
- totalUserSlots
- The total number of user slots that are used by the time series. Equivalent to the number of small element page slots plus the number of large element page directory slots.
- totalSlots
- The total number of slots that are used by the time series. Equivalent to the sum of the number of small element page and header slots and large element page, directory, and header slots.
- totalUserSize
- The total size, in bytes, of the user pages that are used by the time series. Equivalent to the sum of the size of the small element page slots and the large element page slots.
- totalSize
- The total size, in bytes, of the pages that are used by the time series. Equivalent to the sum of the size of the small element pages and the large element pages.
- totalFree
- The total size, in bytes, of free space on both small and large element pages.
- pageSizeDistribution
- The distribution of the fullness of element pages. Equivalent to the sum of the small and large element page distributions. See Distributions.
- memoryUsage
- The amount of shared memory, in bytes, that contains the results of time series functions.
- compressionBuffer
- Information on the compression buffer size and related parameters.
- compressionSessionStats
- Information on the compression stats used in the session. These stats are accumulative during the session and persist until the end of the session.
- rollingWindows
- Controls whether storage information is returned for rolling window containers or standard
containers. If you set the rollingWindows field to
false
, storage information is returned for standard containers. If you set the rollingWindows field totrue
, storage information is returned for both active and dormant windows in rolling window containers, but not for standard containers. The default is to return information about only the active windows in rolling window containers. The output for the rollingWindows field shows the input value as a string.
- begin_tstamp
- The beginning point of the range. Can be NULL, which represents the first element in the time series. If a time stamp is specified, the output value is a string representation of a DATETIME data type in the following format: %Y-%m-%d %H:%M:%S.%F5. For example: 2014-01-01 00:00:00.00000.
- end_tstamp
- The end point of the range. Can be NULL, which represents the last element in the time series. If a time stamp is specified, the output value is a string representation of a DATETIME data type in the following format: %Y-%m-%d %H:%M:%S.%F5. For example: 2014-01-01 00:00:00.00000.
Distributions
Distributions are an array of 10 positions of integer values that each represent a 10% range of space usage. The value that is returned in each position of the array is the number of pages that are the corresponding percentage full. The following table shows the array positions and the corresponding percentage ranges.
Array | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|---|---|---|---|---|---|---|---|---|---|
% | 0 - 10% | 11 - 20% | 21 - 30% | 31 - 40% | 41 - 50% | 51 - 60% | 61 - 70% | 71 - 80% | 81 - 90% | 91 - 100% |
For example, if a time series used 53 small element pages in a container and 48 of the pages are between 95% and 100% full, then the value in the ninth array position is 48. The other five pages are represented in other array positions:
smallElementPage:{distribution:[ 1, 0, 0, 3, 0, 1, 0, 0, 0, 48]}
One page is 0-10% full, three pages are 31-40% full, one page is 51-60% full, and 48 pages are 91-100% full.
Usage
Run the TSInfo function to return information about a time series. By default, the TSInfo function returns detailed information about the storage that is used by the time series and the properties of the time series. Limit the information that is returned by the TSInfo function by specifying the fields that you want in the control parameter.
Include time stamps for the begin_stamp and end_stamp parameters to return information about the time series elements in a specific time range.
The TSInfo function can be CPU intensive, depending on the number of elements for which to gather information and the type of information to return. For example, returning the number of hertz or compressed elements is the most CPU-intensive operation.
Use the following rules for constructing the control parameter:
- If any fields that are listed have a value of
true
, all fields that are not listed are omitted. If you want only specific fields, list only those fields, with the valuetrue
. Any subdocuments for the fields that you list are automatically included. Fields that are not listed are not included. For example, the value{smallElementPage:true}
returns all the values for smallElementPage and no other information. - If you want to return only specific fields but exclude specific
fields in subdocuments, list the subdocuments with a value of
false
and at least one other field with a value oftrue
. For example, the value{smallElementPage:{count:true, size:false}}
returns all the values for smallElementPage except for the value of the size field. - If all fields that are listed have a value of
false
, all fields that are not listed are included. If you want to return all fields except for specific fields, list the fields to omit with a value offalse
and do not list any fields with a value oftrue
. For example, the value{smallElementPage:false, largeElementPage:false}
returns the values for all fields except smallElementPage and largeElementPage.
Returns
A BSON document with the requested field-name value pairs.
Example: Default information
The following statement returns the default information about a time series instance:
SELECT meter_id, tsinfo(readings)::json::lvarchar AS info
FROM sensor_data
WHERE meter_id = 2011;
meter_id 2011
info {"smallElementPage":{"count":2046,"size":8380416,"free":174012,
"distribution":[0,0,0,0,1,0,0,0,0,2045],"slot":{"count":45000,"size":7875000},
"header":{"count":2046,"size":85932},"nullPage":{"count":0}},"largeElementPage":
{"count":0,"size":0,"free":0,"distribution":[0,0,0,0,0,0,0,0,0,0],"slot":{
"count":0,"size":0},"header":{"count":0,"size":0},"directory":{"count":0,"size":
0}},"element":{"count":45000,"notNullCount":45000},"containerPageSize":4096,
"btreeLeafSlotSize":19,"baseTableSize":92,"totalIntervalCount":0,"intervalCount":
{"active":0,"dormant":0},"metadata":{"origin":"2014-01-01 00:00:00.00000",
"calendar":"ts_1sec","container":"container4k_hz_3","threshold":0,"tsid":41,
"irregular":true,"inmem":false,"bigtsid":true,"rollingWindow":false,"hertz":0,
"compression":"","originalOrigin":"2014-01-01 00:00:00.00000"},"totalPages":2046,
"totalUserSlots":45000,"totalSlots":47046,"totalUserSize":7875000,"totalSize":
7960932,"totalFree":174012,"pageSizeDistribution":[0,0,0,0,1,0,0,0,0,2045],
"memoryUsage":{"count":0,"size":0},"rollingWindows":{"active":true}}
Example: Small element page count for a time range
The following statement returns the small element page count for two time series instances over an hour:
SELECT meter_id,info::json::lvarchar AS info, bson_value_bigint(info,
'smallElementPage.count') AS count
FROM(SELECT skip 0 meter_id, tsinfo(readings,
'{smallElementPage:{count:true}}'::json::bson,
'2014-01-01 00:00:00.00000',
'2014-01-01 01:00:00.00000')
FROM ts WHERE meter_id <= 2) AS ti(meter_id, info);
meter_id 1
info {"smallElementPage":{"count":0},"rollingWindows":{"active":true},
"begin_tstamp":"2014-01-01 00:00:00.00000",
"end_tstamp":"2014-01-01 01:00:00.00000"}
count 0
meter_id 2
info {"smallElementPage":{"count":0},"rollingWindows":{"active":true},
"begin_tstamp":"2014-01-01 00:00:00.00000",
"end_tstamp":"2014-01-01 01:00:00.00000"}
count 0
Example: Total number of pages
The following statement returns the total number of pages for two time series instances:
SELECT meter_id, info::json::lvarchar AS info, bson_value_bigint(info,
'totalPages') AS totalpages
FROM (SELECT skip 0 meter_id, tsinfo(readings,
'{totalPages:true}'::json::bson)
FROM devices WHERE meter_id <= 2)
AS ti(meter_id, info);
meter_id 1
info {"totalPages":52,"rollingWindows":{"active":true}}
totalpages 52
meter_id 2
info {"totalPages":32,"rollingWindows":{"active":true}}
totalpages 32
Example: Metadata
The following statement returns the metadata information for two time series instances:
SELECT meter_id,info::json::lvarchar FROM
(SELECT skip 0 meter_id, tsinfo(readings, '{metadata:true}'::json::bson)
FROM devices WHERE meter_id <= 2) AS ti(meter_id, info);
meter_id 1
info {"metadata":{"origin":"2012-06-01 00:00:00.00000","calendar":
"ts_1min","container":"container4k_1","threshold":0,"tsid":17,"irregular":true,
"inmem":false,"bigtsid":true,"rollingWindow":true,"hertz":0,"compression":"",
"originalOrigin":"2012-06-01 00:00:00.00000","refCount":1},
"rollingWindows":{"active":true}}
meter_id 2
info {"metadata":{"origin":"2012-06-01 00:00:00.00000","calendar":
"ts_1min","container":"container4k_2","threshold":0,"tsid":18,"irregular":false,
"inmem":false,"bigtsid":true,"rollingWindow":true,"hertz":0,"compression":"",
"originalOrigin":"2014-01-01 00:00:00.00000","refCount":1},
"rollingWindows":{"active":true}}