Matthew Halko
02/23/2023, 9:51 PMImre
02/24/2023, 10:12 AMMatthew Halko
02/24/2023, 3:03 PMImre
02/24/2023, 4:39 PMSELECT symbol, sum(amount) as volume, min(price) as minimum, max(price) as maximum, round((max(price)+min(price))/2, 2) as mid, timestamp as ts FROM trades sample by 1m ALIGN to CALENDAR
i have 1.3 million rows in the table, the query returns with 4320 rows.
mem usage seems to be constant.
using jconsole and htop.
java heap mem usage is 200-800 MB.
htop shows the server uses 1.2-1.8 GB, moves together with java heap mem.
when i press ‘Perform GC’ in jconsole the mem usage drops to 1.2 GB.Matthew Halko
02/24/2023, 4:41 PMImre
02/24/2023, 4:46 PMMatthew Halko
02/24/2023, 4:46 PMImre
02/24/2023, 4:47 PMMatthew Halko
02/24/2023, 4:48 PMImre
02/24/2023, 4:48 PMMatthew Halko
02/24/2023, 4:50 PMImre
02/24/2023, 4:50 PMMatthew Halko
02/24/2023, 4:51 PMImre
02/24/2023, 4:53 PMMatthew Halko
02/24/2023, 4:57 PMImre
02/24/2023, 4:57 PM2023-02-24T17:43:37.609078Z A server-main enjoy
2023-02-24T17:43:44.345190Z I pg-server connected [ip=127.0.0.1, fd=128]
2023-02-24T17:43:44.346485Z I i.q.c.p.PGConnectionContext protocol [major=3, minor=0]
2023-02-24T17:43:44.366186Z I i.q.c.p.PGConnectionContext parse [fd=128, q=SET extra_float_digits = 3]
2023-02-24T17:43:44.366595Z I i.q.c.p.PGConnectionContext parse [fd=128, q=SET application_name = 'PostgreSQL JDBC Driver']
2023-02-24T17:43:44.374469Z I i.q.c.p.PGConnectionContext parse [fd=128, q=SELECT * FROM (SELECT symbol, sum(amount) as volume, min(price) as minimum, max(price) as maximum, round((max(price)+min(price))/2, 2) as mid, timestamp as ts FROM trades sample by 1m ALIGN to CALENDAR) SPARK_GEN_SUBQ_0 WHERE 1=0]
2023-02-24T17:43:44.375049Z I i.q.c.p.ReaderPool open 'trades~10' [at=0:0]
2023-02-24T17:43:44.375613Z I i.q.c.p.ReaderPool 'trades~10' is back [at=0:0, thread=18]
2023-02-24T17:43:44.375991Z I i.q.g.SqlCompiler plan [q=`select-choose symbol, volume, minimum, maximum, mid, ts from (select [symbol, volume, minimum, maximum, mid, ts] from (select-virtual [symbol, volume, minimum, maximum, round(maximum + minimum / 2,2) mid, ts] symbol, volume, minimum, maximum, round(maximum + minimum / 2,2) mid, ts from (select-group-by [symbol, sum(amount) volume, min(price) minimum, max(price) maximum, ts] symbol, sum(amount) volume, min(price) minimum, max(price) maximum, ts from (select-choose [symbol, amount, price, timestamp ts] symbol, amount, price, timestamp ts from (select [symbol, amount, price, timestamp] from trades timestamp (timestamp))) sample by 1m align to calendar with offset '00:00')) SPARK_GEN_SUBQ_0 where 1 = 0) SPARK_GEN_SUBQ_0`, fd=128]
2023-02-24T17:43:44.376084Z I i.q.c.p.ReaderPool assign 'trades~10' [at=0:0]
2023-02-24T17:43:44.376140Z I i.q.c.p.ReaderPool 'trades~10' is back [at=0:0, thread=18]
2023-02-24T17:43:44.389639Z I pg-server scheduling disconnect [fd=128, reason=15]
2023-02-24T17:43:44.389722Z I pg-server disconnected [ip=127.0.0.1, fd=128, src=queue]
2023-02-24T17:43:45.128877Z I pg-server connected [ip=127.0.0.1, fd=128]
2023-02-24T17:43:45.129224Z I i.q.c.p.PGConnectionContext protocol [major=3, minor=0]
2023-02-24T17:43:45.129861Z I i.q.c.p.PGConnectionContext parse [fd=128, q=SET extra_float_digits = 3]
2023-02-24T17:43:45.130051Z I i.q.c.p.PGConnectionContext parse [fd=128, q=SET application_name = 'PostgreSQL JDBC Driver']
2023-02-24T17:43:45.130524Z I i.q.c.p.PGConnectionContext parse [fd=128, q=SELECT * FROM (SELECT symbol, sum(amount) as volume, min(price) as minimum, max(price) as maximum, round((max(price)+min(price))/2, 2) as mid, timestamp as ts FROM trades sample by 1m ALIGN to CALENDAR) SPARK_GEN_SUBQ_8 WHERE 1=0]
2023-02-24T17:43:45.130937Z I i.q.c.p.ReaderPool assign 'trades~10' [at=0:0]
2023-02-24T17:43:45.130991Z I i.q.c.p.ReaderPool 'trades~10' is back [at=0:0, thread=18]
2023-02-24T17:43:45.131287Z I i.q.g.SqlCompiler plan [q=`select-choose symbol, volume, minimum, maximum, mid, ts from (select [symbol, volume, minimum, maximum, mid, ts] from (select-virtual [symbol, volume, minimum, maximum, round(maximum + minimum / 2,2) mid, ts] symbol, volume, minimum, maximum, round(maximum + minimum / 2,2) mid, ts from (select-group-by [symbol, sum(amount) volume, min(price) minimum, max(price) maximum, ts] symbol, sum(amount) volume, min(price) minimum, max(price) maximum, ts from (select-choose [symbol, amount, price, timestamp ts] symbol, amount, price, timestamp ts from (select [symbol, amount, price, timestamp] from trades timestamp (timestamp))) sample by 1m align to calendar with offset '00:00')) SPARK_GEN_SUBQ_8 where 1 = 0) SPARK_GEN_SUBQ_8`, fd=128]
2023-02-24T17:43:45.131354Z I i.q.c.p.ReaderPool assign 'trades~10' [at=0:0]
2023-02-24T17:43:45.131408Z I i.q.c.p.ReaderPool 'trades~10' is back [at=0:0, thread=18]
2023-02-24T17:43:45.132277Z I pg-server scheduling disconnect [fd=128, reason=15]
2023-02-24T17:43:45.132323Z I pg-server disconnected [ip=127.0.0.1, fd=128, src=queue]
2023-02-24T17:43:45.142150Z I pg-server connected [ip=127.0.0.1, fd=128]
2023-02-24T17:43:45.142363Z I i.q.c.p.PGConnectionContext protocol [major=3, minor=0]
2023-02-24T17:43:45.142720Z I i.q.c.p.PGConnectionContext parse [fd=128, q=SET extra_float_digits = 3]
2023-02-24T17:43:45.142905Z I i.q.c.p.PGConnectionContext parse [fd=128, q=SET application_name = 'PostgreSQL JDBC Driver']
2023-02-24T17:43:45.143261Z I i.q.c.p.PGConnectionContext parse [fd=128, q=SELECT * FROM (SELECT symbol, sum(amount) as volume, min(price) as minimum, max(price) as maximum, round((max(price)+min(price))/2, 2) as mid, timestamp as ts FROM trades sample by 1m ALIGN to CALENDAR) SPARK_GEN_SUBQ_16 WHERE 1=0]
2023-02-24T17:43:45.143604Z I i.q.c.p.ReaderPool assign 'trades~10' [at=0:0]
2023-02-24T17:43:45.143640Z I i.q.c.p.ReaderPool 'trades~10' is back [at=0:0, thread=18]
2023-02-24T17:43:45.143897Z I i.q.g.SqlCompiler plan [q=`select-choose symbol, volume, minimum, maximum, mid, ts from (select [symbol, volume, minimum, maximum, mid, ts] from (select-virtual [symbol, volume, minimum, maximum, round(maximum + minimum / 2,2) mid, ts] symbol, volume, minimum, maximum, round(maximum + minimum / 2,2) mid, ts from (select-group-by [symbol, sum(amount) volume, min(price) minimum, max(price) maximum, ts] symbol, sum(amount) volume, min(price) minimum, max(price) maximum, ts from (select-choose [symbol, amount, price, timestamp ts] symbol, amount, price, timestamp ts from (select [symbol, amount, price, timestamp] from trades timestamp (timestamp))) sample by 1m align to calendar with offset '00:00')) SPARK_GEN_SUBQ_16 where 1 = 0) SPARK_GEN_SUBQ_16`, fd=128]
2023-02-24T17:43:45.143976Z I i.q.c.p.ReaderPool assign 'trades~10' [at=0:0]
2023-02-24T17:43:45.144024Z I i.q.c.p.ReaderPool 'trades~10' is back [at=0:0, thread=18]
2023-02-24T17:43:45.144785Z I pg-server scheduling disconnect [fd=128, reason=15]
2023-02-24T17:43:45.144834Z I pg-server disconnected [ip=127.0.0.1, fd=128, src=queue]
2023-02-24T17:43:45.152545Z I pg-server connected [ip=127.0.0.1, fd=128]
2023-02-24T17:43:45.152802Z I i.q.c.p.PGConnectionContext protocol [major=3, minor=0]
2023-02-24T17:43:45.153271Z I i.q.c.p.PGConnectionContext parse [fd=128, q=SET extra_float_digits = 3]
2023-02-24T17:43:45.153489Z I i.q.c.p.PGConnectionContext parse [fd=128, q=SET application_name = 'PostgreSQL JDBC Driver']
2023-02-24T17:43:45.153921Z I i.q.c.p.PGConnectionContext parse [fd=128, q=SELECT * FROM (SELECT symbol, sum(amount) as volume, min(price) as minimum, max(price) as maximum, round((max(price)+min(price))/2, 2) as mid, timestamp as ts FROM trades sample by 1m ALIGN to CALENDAR) SPARK_GEN_SUBQ_24 WHERE 1=0]
2023-02-24T17:43:45.154203Z I i.q.c.p.ReaderPool assign 'trades~10' [at=0:0]
2023-02-24T17:43:45.154234Z I i.q.c.p.ReaderPool 'trades~10' is back [at=0:0, thread=18]
2023-02-24T17:43:45.154460Z I i.q.g.SqlCompiler plan [q=`select-choose symbol, volume, minimum, maximum, mid, ts from (select [symbol, volume, minimum, maximum, mid, ts] from (select-virtual [symbol, volume, minimum, maximum, round(maximum + minimum / 2,2) mid, ts] symbol, volume, minimum, maximum, round(maximum + minimum / 2,2) mid, ts from (select-group-by [symbol, sum(amount) volume, min(price) minimum, max(price) maximum, ts] symbol, sum(amount) volume, min(price) minimum, max(price) maximum, ts from (select-choose [symbol, amount, price, timestamp ts] symbol, amount, price, timestamp ts from (select [symbol, amount, price, timestamp] from trades timestamp (timestamp))) sample by 1m align to calendar with offset '00:00')) SPARK_GEN_SUBQ_24 where 1 = 0) SPARK_GEN_SUBQ_24`, fd=128]
2023-02-24T17:43:45.154517Z I i.q.c.p.ReaderPool assign 'trades~10' [at=0:0]
2023-02-24T17:43:45.154563Z I i.q.c.p.ReaderPool 'trades~10' is back [at=0:0, thread=18]
2023-02-24T17:43:45.155332Z I pg-server scheduling disconnect [fd=128, reason=15]
2023-02-24T17:43:45.155373Z I pg-server disconnected [ip=127.0.0.1, fd=128, src=queue]
2023-02-24T17:43:44.375049Z I i.q.c.p.ReaderPool open 'trades~10' [at=0:0]
2023-02-24T17:43:44.375613Z I i.q.c.p.ReaderPool 'trades~10' is back [at=0:0, thread=18]
then always:
2023-02-24T17:43:45.130937Z I i.q.c.p.ReaderPool assign 'trades~10' [at=0:0]
2023-02-24T17:43:45.130991Z I i.q.c.p.ReaderPool 'trades~10' is back [at=0:0, thread=18]
and it is always at=0:0
so the same reader at the same index in the pool is reused.AbstractMultiTenantPool open 'trades~10' [at=0:0]