Shriram Sunder
09/04/2022, 7:57 PM// Push to db
err := sender.Table("urls").
Symbol("ticker", ticker).
StringColumn("start", dp.Start.Format(TimeLayout)).
StringColumn("end", dp.End.Format(TimeLayout)).
StringColumn("url", u.String()).
BoolColumn("done", false).
At(ctx, time.Now().UnixNano())
How would one correct this statement? Any examples would be of massive help.Shriram Sunder
09/05/2022, 4:07 PMInvalid column: q.timestamp
error ONLY when I include both the conditions.
WITH q AS (
SELECT ticker, timestamp
FROM aggs
LATEST ON timestamp
PARTITION BY ticker
)
UPDATE urls u
SET done = true
FROM q
WHERE q.timestamp <= u.end
AND q.ticker = u.ticker;
2. This query below works however.
WITH q AS (
SELECT ticker, timestamp
FROM aggs
LATEST ON timestamp
PARTITION BY ticker
)
UPDATE urls u
SET done = true
FROM q
WHERE q.timestamp <= u.end;
--AND q.ticker = u.ticker;
3. And this query works.
WITH q AS (
SELECT ticker, timestamp
FROM aggs
LATEST ON timestamp
PARTITION BY ticker
)
UPDATE urls u
SET done = true
FROM q
WHERE q.ticker = u.ticker;
What's the issue with the first statement ?
Obviously, I don't need just one condition, I need both of them.
The schema for 'aggs' is as follows:
CREATE TABLE 'aggs' (
ticker SYMBOL capacity 256 CACHE,
timespan STRING,
multiplier LONG,
open DOUBLE,
high DOUBLE,
low DOUBLE,
close DOUBLE,
volume DOUBLE,
vw DOUBLE,
n DOUBLE,
timestamp TIMESTAMP
) timestamp (timestamp) PARTITION BY DAY;
The schema for 'urls' is as follows:
CREATE TABLE 'urls' (ticker SYMBOL capacity 256 CACHE, start TIMESTAMP,end TIMESTAMP,
url STRING,
done BOOLEAN
) timestamp (end) PARTITION BY DAY;
I think it's related to this issue: https://github.com/questdb/questdb/issues/2329javier ramirez
09/05/2022, 5:18 PMjavier ramirez
09/05/2022, 5:18 PMWITH q AS (
SELECT ticker, timestamp
FROM aggs
LATEST ON timestamp
PARTITION BY ticker
), q_url AS (
select q.* from q join urls on(ticker)
WHERE `timestamp` <= end
)
UPDATE urls u
SET done = true
FROM q_url
where u.ticker = q_url.ticker;
Shriram Sunder
09/06/2022, 5:49 AMxieyang
09/28/2022, 1:39 AMAndrew Bannerman
10/03/2022, 5:06 PM2022-10-03T16:00:33.665746Z I i.q.c.l.t.LineTcpMeasurementScheduler idle table going active [tableName=es_ticks]
2022-10-03T16:00:33.665747Z I i.q.c.l.t.TableUpdateDetails closing table writer [tableName=es_ticks]
2022-10-03T16:00:33.665748Z I i.q.c.l.t.TableUpdateDetails closing table parsers [tableName=es_ticks]
2022-10-03T16:00:33.665753Z I i.q.c.l.t.TableUpdateDetails closing table parsers [tableName=es_ticks]
`2022-10-03T16:00:33.665772Z I i.q.c.p.WriterPool open [table=es_ticks
, thread=24]`
2022-10-03T16:00:33.665821Z I i.q.c.TableWriter open 'es_ticks'
2022-10-03T16:00:33.667156Z I i.q.c.TableWriter switched partition [path='/var/lib/questdb/db/es_ticks/2022-10-03.1842']
2022-10-03T16:00:33.667586Z I i.q.c.TableWriter purging non attached partitions [path=/var/lib/questdb/db/es_ticks]
`2022-10-03T16:00:33.667879Z I i.q.c.p.WriterPool >> [table=es_ticks
, thread=24]`
2022-10-03T16:00:33.667888Z I i.q.c.l.t.LineTcpMeasurementScheduler assigned es_ticks to thread 0
2022-10-03T16:00:33.667892Z I i.q.c.l.t.TableUpdateDetails network IO thread using table [workerId=1, tableName=es_ticks, nNetworkIoWorkers=1]
2022-10-03T16:00:33.667897Z I i.q.c.p.ReaderPool open 'es_ticks' [at=0:0]
2022-10-03T16:00:33.668038Z I tcp-line-server scheduling disconnect [fd=39, reason=0]
2022-10-03T16:00:33.668041Z I tcp-line-server disconnected [ip=172.17.0.1, fd=39, src=queue]
2022-10-03T16:00:33.668093Z I tcp-line-server connected [ip=172.17.0.1, fd=39]
2022-10-03T16:00:33.668096Z I tcp-line-server connected [ip=172.17.0.1, fd=126]
2022-10-03T16:00:33.668098Z I tcp-line-server connected [ip=172.17.0.1, fd=127]
2022-10-03T16:00:33.668100Z I tcp-line-server connected [ip=172.17.0.1, fd=128]
2022-10-03T16:00:33.668102Z I tcp-line-server connected [ip=172.17.0.1, fd=129]
2022-10-03T16:00:33.668106Z I tcp-line-server connected [ip=172.17.0.1, fd=130]
2022-10-03T16:00:33.668124Z I tcp-line-server scheduling disconnect [fd=92, reason=0]
2022-10-03T16:00:33.668125Z I tcp-line-server disconnected [ip=172.17.0.1, fd=92, src=queue]
2022-10-03T16:00:33.668158Z I tcp-line-server scheduling disconnect [fd=93, reason=0]
2022-10-03T16:00:33.668159Z I tcp-line-server disconnected [ip=172.17.0.1, fd=93, src=queue]
2022-10-03T16:00:33.668180Z I tcp-line-server scheduling disconnect [fd=94, reason=0]
2022-10-03T16:00:33.668181Z I tcp-line-server disconnected [ip=172.17.0.1, fd=94, src=queue]
2022-10-03T16:00:33.668199Z I tcp-line-server scheduling disconnect [fd=95, reason=0]
2022-10-03T16:00:33.668200Z I tcp-line-server disconnected [ip=172.17.0.1, fd=95, src=queue]
2022-10-03T16:00:33.668218Z I tcp-line-server scheduling disconnect [fd=96, reason=0]
2022-10-03T16:00:33.668219Z I tcp-line-server disconnected [ip=172.17.0.1, fd=96, src=queue]
2022-10-03T16:00:33.668237Z I tcp-line-server scheduling disconnect [fd=97, reason=0]
2022-10-03T16:00:33.668238Z I tcp-line-server disconnected [ip=172.17.0.1, fd=97, src=queue]
2022-10-03T16:00:33.668261Z I tcp-line-server scheduling disconnect [fd=98, reason=0]
Andrew Bannerman
10/03/2022, 5:06 PM2022-10-03T16:00:40.275261Z I tcp-line-server connected [ip=172.17.0.1, fd=39]
2022-10-03T16:00:40.275563Z I tcp-line-server scheduling disconnect [fd=39, reason=0]
Andrew Bannerman
10/03/2022, 5:07 PMAndrew Bannerman
10/03/2022, 5:08 PM<http://localhost:9000/#>
I can see the data is in there and I can run queries.
I would say sometimes the data is not available for query until maybe 1 to 2 minutes later - i have tried to play with the buffer sizes in this regard. But really I am trying to gauge If my setup is correct.Andrew Bannerman
10/03/2022, 5:10 PMAndrew Bannerman
10/03/2022, 5:10 PMAndrew Bannerman
10/04/2022, 12:20 AMwith Sender(HOST, PORT) as sender:
try:
on each tick row.Andrew Bannerman
10/04/2022, 2:10 AMdef connectionSender():
global sender
sender = Sender(HOST, PORT)
sender.connect()
Then I have a separate function which which creates the new rows from the incoming data from the broker:
def buffer_Send(bidPrice, askPrice, bidSize, askSize, year, month, day, hour, minute, second):
try:
buf = Buffer(init_capacity=1024, max_name_len=127)
buf.row(
'es_ticks',
columns={
'bidPrice': bidPrice,
'askPrice': askPrice,
'bidSize': int(bidSize),
etc...
and sends the data to the databaseAndrew Bannerman
10/04/2022, 2:11 AMShriram Sunder
10/05/2022, 11:51 PMShriram Sunder
10/05/2022, 11:57 PMruntime error: invalid memory address or nil pointer dereference
// Send the data to QDB, if response is not empty
if res.Results != nil {
// Connect to QDB and get sender
sender, _ := qdb.NewLineSender(ctx)
for _, v := range res.Results {
err := sender.Table("aggs").
Symbol("ticker", res.Ticker).
StringColumn("timespan", "minute").
Int64Column("multiplier", int64(1)).
Float64Column("open", v.O).
Float64Column("high", v.H).
Float64Column("low", v.L).
Float64Column("close", v.C).
Float64Column("volume", v.V).
Float64Column("vw", v.Vw).
Float64Column("n", float64(v.N)).
At(ctx, time.UnixMilli(int64(v.T)).UnixNano())
db.CheckErr(err)
}
// Make sure the sender is flushed
err = sender.Flush(ctx)
db.CheckErr(err)
// Close the sender.
err = sender.Close()
db.CheckErr(err)
}
Newskooler
10/06/2022, 12:21 PMJiri Pokorny
10/21/2022, 11:41 AM-e QDB_LINE_TCP_MSG_BUFFER_SIZE=5000000 -e QDB_LINE_TCP_MAX_MEASUREMENT_SIZE=5000000
However, now the container just starts and ends without any explicit error, maybe it runs out of memory? Any advice regarding large messages and about how to tune these kind of parameters and how they sum up to total memory consumption of QuestDB process?Marcus Horsley
10/21/2022, 12:20 PMsender
each iteration; intermittently I get errors like Got error: Could not flush buffer: Connection reset by peer (os error 104)
can anyone point me in the right direction to understand this?Pei
10/27/2022, 3:31 PMShriram Sunder
10/28/2022, 9:45 PMsender
's not being released. I am on a Windows 11 system, and as mentioned there's a limit of 200 connections in Windows. I've modified that to 10000 from the config file as well, yet I'm getting the following error:
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x40 pc=0x104dfdc]
The error code points to this section of the code:
// Go Func to insert data into the database, reads from the channel
go func() {
// Makes sure wg closes
defer wg.Done()
// Make a goroutine that will accept data from a channel and push to questDB
ctx, cancel := context.WithCancel(context.Background())
// Get newline sender
sender, err := qdb.NewLineSender(ctx)
db.CheckErr(err)
// Defer close the sender
defer func() {
if err = sender.Close(); err != nil {
fmt.Println(err)
}
}()
// Get the values from the channel
for res := range c {
for _, v := range res.Results {
err := sender.Table("aggs").
Symbol("ticker", res.Ticker).
StringColumn("timespan", "minute").
Int64Column("multiplier", int64(1)).
Float64Column("open", v.O).
Float64Column("high", v.H).
Float64Column("low", v.L).
Float64Column("close", v.C).
Float64Column("volume", v.V).
Float64Column("vw", v.Vw).
Float64Column("n", float64(v.N)).
At(ctx, time.UnixMilli(int64(v.T)).UnixNano())
db.CheckErr(err)
}
// Make sure the sender is flushed
err := sender.Flush(ctx)
db.CheckErr(err)
}
// Cancel the context
cancel()
}()
It's definitely a case of connections to the database not being closed, as there was a delay in the error, AFTER increasing the number of connections to the db.
I've even tied it to the context, and it simply does not release the connection, any suggestions are welcome.Andrey Pechkurov
10/29/2022, 7:02 AMClose()
correctly. It looks like it will be closed only when the c
channel is explicitly closed, so that the goroutine execution finishes. Are you sure you're closing the channel? One more question: how many of these goroutines do you start? If you're not trying to ingest more than 300-500 thousand rows per second, you should be fine with a single TCP connection - no need to open lots of them.Randy Sun
11/07/2022, 4:02 AMFranco Almonacid
11/10/2022, 2:36 PMD status
.
A peak looks something like this:
Table 1: 6000 rows per second
Table 2: 2000 rows per second
Table 3: 3000 rows per second
Table 4: 1000 rows per second
Table config:
maxUncommittedRows = 100000
commitLag = 4s
GCP Instance:
8 CPU
32GB RAM
SSD
Are we missing any config? or do you guys have any tip for tuning QuestDB?Franco Almonacid
11/10/2022, 2:42 PMQuestDB 6.5.3
javier ramirez
11/10/2022, 4:29 PMjavier ramirez
11/10/2022, 4:30 PMFranco Almonacid
11/10/2022, 4:33 PMFranco Almonacid
11/10/2022, 4:34 PM2022-11-08T22:42:15.460592Z I i.q.c.TableWriter sorting o3 [table=trades]
2022-11-08T22:42:15.460644Z I i.q.c.TableWriter sorted [table=trades]
Franco Almonacid
11/10/2022, 4:34 PM2022-11-08T22:42:15.460592Z I i.q.c.TableWriter sorting o3 [table=trades]
2022-11-08T22:42:15.460644Z I i.q.c.TableWriter sorted [table=trades]