Hello Everybody
i am developing netflow monitor and i am stuck in mysql 5.7 on windows PC.
The application i am working on only for windows PC
I have netflow packets (30 000 per sec) and i need to insert them to DB
I created innodb table with partitions ( 1 partition for 1 day).
This is table structure
CREATE TABLE IF NOT EXISTS netflow_1 (
id
int(10) unsigned NOT NULL AUTO_INCREMENT,
stimestamp
int(10) unsigned NOT NULL,
flow_start_time
int(10) unsigned NOT NULL,
input_snmp
SMALLINT(5) unsigned DEFAULT NULL,
output_snmp
SMALLINT(5) unsigned DEFAULT NULL,
direction
TINYINT(3) unsigned DEFAULT NULL,
ipv4_src_addr
int(11) unsigned DEFAULT NULL,
ipv4_dst_addr
int(11) unsigned DEFAULT NULL,
netflow_bytes
BIGINT(20) unsigned DEFAULT NULL,
protocol
TINYINT(3) unsigned DEFAULT NULL,
l4_src_port
SMALLINT(5) unsigned DEFAULT NULL,
l4_dst_port
SMALLINT(5) unsigned DEFAULT NULL,
src_as
SMALLINT(5) unsigned DEFAULT NULL,
dst_as
SMALLINT(5) unsigned DEFAULT NULL,
PRIMARY KEY (id
,stimestamp
),
KEY idx_stimestamp
(stimestamp
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
PARTITION BY RANGE (stimestamp) (
PARTITION p2017_12_01 VALUES LESS THAN (UNIX_TIMESTAMP(“2017-12-02”))
);
And i use procedure to insert data . It takes me 45-50 sec to insert 1 million records
How to improve i do not know
Also how to
1 - select port, sum(netflow_bytes) as _netflow_sum from netflow_1 where stimestamp > 0 and stimestamp < 4000000 group by port order by _netflow_sum desc limit 0,10;
2 - select src_as, dst_as, sum(netflow_bytes) as _netflow_sum from netflow_1 where stimestamp > 0 and stimestamp < 4000000 group by concat(src_as, dst_as) desc limit 0 , 10;
User should be able to select netflow by time range. In GUI it is usual table with pagination and calendar.
Netflow data will be stored during 30 days. It means the table with have 30 partitions.
Thanks for any advice