commit
9c8bde2315
|
@ -0,0 +1,42 @@
|
|||
# Small Materialized Aggragates
|
||||
|
||||
**SMA** (**S**mall **M**aterialized **A**ggrates) is used to speed up the query process on materialized data cube in TDengine. TDengine 3.0 gives more flexibility on the SMA configurations.
|
||||
|
||||
There are two kinds of SMA in TDengine:
|
||||
1. Block-wise SMA
|
||||
2. Time-range-wise SMA
|
||||
|
||||
<!--
|
||||
```plantuml
|
||||
@startmindmap mind_map_test
|
||||
* SMA
|
||||
** Block-wise SMA
|
||||
** Time-range-wise SMA
|
||||
@endmindmap
|
||||
``` -->
|
||||
|
||||

|
||||
## Block-wise SMA
|
||||
Block-wise SMA is created by default when the data are committed. Since time-series data are saved as block data in files, a corresponding SMA is create when the data block is written. The default block-wise SMA includes:
|
||||
1. sum(*)
|
||||
2. max(*)
|
||||
3. min(*)
|
||||
|
||||
By default, the system will create SMA for each column except those columns with type *binary* and *nchar*. However, users can change the behavior by the keyword **NOSMA** to disable the SMA for a certain column like below:
|
||||
```SQL
|
||||
# create a super table with the SMA on column b disabled
|
||||
create table st (ts timestamp, a int, b int NOSMA, c double) tags (tg1 binary(10), tg2 int);
|
||||
```
|
||||
|
||||
## Time-range-wise SMA
|
||||
In addition to the default block-wise SMA, users can create their own SMAs ondemand. Below is an example to create a SMA.
|
||||
```SQL
|
||||
# create a SMA every 10 minutes with SMA of sum, max and min
|
||||
create sma_indx sma_10min on st (sum(*), max(*), min(*), twa(*)) interval(10m);
|
||||
```
|
||||
Users can also drop a time-range-wise SMA like below:
|
||||
```SQL
|
||||
# drop the sma index
|
||||
drop sma_index sma_5min on st;
|
||||
```
|
||||
**NOTE: Creating an SMA index is a heavy operation which may take a long time and block the write operation. So create the time-range-wise SMA when creating the table or when there are not too much data.**
|
|
@ -1,26 +1,4 @@
|
|||
add_subdirectory(meta)
|
||||
add_subdirectory(tq)
|
||||
add_subdirectory(tsdb)
|
||||
|
||||
aux_source_directory(src VNODE_SRC)
|
||||
add_library(vnode STATIC ${VNODE_SRC})
|
||||
target_include_directories(
|
||||
vnode
|
||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/server/vnode"
|
||||
private "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
target_link_libraries(
|
||||
vnode
|
||||
PUBLIC transport
|
||||
PUBLIC meta
|
||||
PUBLIC tq
|
||||
PUBLIC tsdb
|
||||
PUBLIC wal
|
||||
PUBLIC sync
|
||||
PUBLIC cjson
|
||||
)
|
||||
|
||||
# test
|
||||
if(${BUILD_TEST})
|
||||
add_subdirectory(test)
|
||||
endif(${BUILD_TEST})
|
||||
add_subdirectory(impl)
|
|
@ -0,0 +1,22 @@
|
|||
aux_source_directory(src VNODE_SRC)
|
||||
add_library(vnode STATIC ${VNODE_SRC})
|
||||
target_include_directories(
|
||||
vnode
|
||||
PUBLIC "${CMAKE_SOURCE_DIR}/include/server/vnode"
|
||||
private "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
target_link_libraries(
|
||||
vnode
|
||||
PUBLIC transport
|
||||
PUBLIC meta
|
||||
PUBLIC tq
|
||||
PUBLIC tsdb
|
||||
PUBLIC wal
|
||||
PUBLIC sync
|
||||
PUBLIC cjson
|
||||
)
|
||||
|
||||
# test
|
||||
if(${BUILD_TEST})
|
||||
add_subdirectory(test)
|
||||
endif(${BUILD_TEST})
|
Loading…
Reference in New Issue