$ ./configure --prefix=${HOME}/tcq-tools
$ make
$ make test
$ make install
$ ./configure --prefix=${HOME}/tcq-tools
$ make
$ make check
$ make install
$ ./configure-tcq
$ make
$ make install
initdb initializes the data directories, the shared catalogs and performs other administrivia like, locale and character set encoding. As an alternative to the -D option, you can set PGDATA to point to the data directory on the file system. By passing it the --no-locale flag, initdb inherits the locale from it's environment.
$ initdb --no-locale -D ${PGDATA}
createdb creates a new PostgreSQL database. pg_ctl start|stop|restart are commands used to start/stop or restart a PostgreSQL server. logfile-name specifies the file to which all status messages are logged.
$ pg_ctl start -D ${PGDATA} -l <logfile-name>
$ createdb ${DBNAME}
$ pg_ctl stop -D ${PGDATA} -l <logfile-name>
pg_ctl passes all the options within the -o flag to the postmaster, which is the PostgreSQL multi-user database server.
$ pg_ctl start -D ${PGDATA} -l logfile-name -o " -t database-name -u \
user-name -G -i -Q 64 -d 1"
psql is an interactive client to PostgreSQL. It allows you to pose queries and see the results.
$ psql -C database-name
tcqtime is the default timestamp column which obeys the TIMESTAMPCOLUMN constraint. It specifies the creation time of a tuple, which are assumed to be monotonically increasing. Tuples entering TelegraphCQ can either be externally time-stamped, or time-stamped by the data source. If they're time-stamped by a TelegraphCQ data source like the CSV Wrapper, they will be in monotonically increasing order.
Welcome to psql 0.2, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
starting in CQ Query mode. All queries will be submitted using cursors.
sample=# CREATE SCHEMA traffic;
sample=# CREATE STREAM traffic.measurements (stationid INT,
speed REAL,
tcqtime TIMESTAMP TIMESTAMPCOLUMN
) TYPE ARCHIVED;
Wrappers are user-defined data acquistion functions in TelegraphCQ. ALTER STREAM associates the stream with a CSV wrapper. A CSV wrapper, that can handle input in the Comma Separated Value file format, comes bundled with TelegraphCQ.
sample=# ALTER STREAM traffic.measurements ADD WRAPPER csvwrapper;
The window clause [RANGE BY ... SLIDE BY ... START AT ...] defines a window over potentially infinite input data stream, thereby placing a bound on it and enabling us to return results without waiting for the entire data stream to be processed. The RANGE parameter defines the size of the window in number of seconds, and the SLIDE parameter defines the interval after which this window will be re-calculated, again in number of seconds. The START AT parameter defines the time at which the first window begins.
sample=# SELECT dst, COUNT(*), wtime(*) AS c FROM network.tcpdump AS st
[RANGE BY '5 seconds' SLIDE BY '1 second' START AT '2003-06-06 18:50:20']
GROUP BY dst;
tcpdump.log is a CSV file containing a dump of TCP message headers, produced by the UNIX command tcpdump, a snippet of which is given below:
$ cat tcpdump.log | source.pl localhost 5533 csvwrapper,network.tcpdump
source.pl is a Perl script connects and feeds data to the wrapper clearinghouse, which is a dedicated process that listens to connection requests from new data sources. By default, it listens on port 5533. In addition, we also specify the wrapper type and the schema of the stream we're providing input to. wtime is a special aggregate over windows which returns the latest timestamp of all tuples in that window. A snippet of the query result is given below:
128.32.37.185,32797,64.174.7.0,80,S,06/06/2003 18:50:20.856709
128.32.37.185,32797,64.174.7.1,80,S,06/06/2003 18:50:21.856709
128.32.37.185,32797,64.174.7.2,80,S,06/06/2003 18:50:22.856709
128.32.37.185,32797,64.174.7.3,80,S,06/06/2003 18:50:23.856709
128.32.37.185,32797,64.174.7.4,80,S,06/06/2003 18:50:24.856709
128.32.37.185,32797,64.174.7.5,80,S,06/06/2003 18:50:25.856709
dst | count | c
---------------+-------+---------------------
64.174.7.0/32 | 1 | 2003-06-06 18:50:25
64.174.7.1/32 | 1 | 2003-06-06 18:50:25
64.174.7.2/32 | 1 | 2003-06-06 18:50:25
64.174.7.3/32 | 1 | 2003-06-06 18:50:25
64.174.7.4/32 | 1 | 2003-06-06 18:50:25
64.174.7.1/32 | 1 | 2003-06-06 18:50:26
64.174.7.2/32 | 1 | 2003-06-06 18:50:26
SELECT
R.i, R.j, count(*)
FROM
R [RANGE BY 't1 seconds' SLIDE BY 't2 seconds'],
S [RANGE BY 't3 seconds' SLIDE BY 't4 seconds']
WHERE
R.k = S.k
GROUP BY
R.i, R.j
HAVING
R.j > C;
WITH
StreamOne AS
(
SELECT R.i, sum(R.j) as sum, wtime(*)
FROM R [RANGE BY 't1 seconds' SLIDE BY 't2 seconds']
)
StreamTwo AS
(
SELECT S.k, sum(S.l) as sum, wtime(*)
FROM S [RANGE BY 't3 seconds' SLIDE BY 't4 seconds']
)
(SELECT * FROM StreamOne S1, StreamTwo S2
WHERE S1.i = S2.k);
SELECT
SUM(R.i), AVG(R.j), COUNT(*), wtime(*)
FROM
R [RANGE BY 't1 seconds' SLIDE BY 't2 seconds'];
Filters | These represent single-table qualifications in the query. They are always of the form column OP constant. These filter modules will be merged together by the eddy to form a grouped filter which can evaluate filter predicates for multiple queries simultaneously. |
SteMs | The building blocks for continuous query joins. A SteM holds tuples for a particular base relation or stream, and can be probed efficiently to find data tuples which match a probe tuple. |
Table or stream Scans | These scans are used to obtain data from TelegraphCQ streams or regular PostgreSQL relations. |