Hi, I have a small problem with a program I've developed.

It basically captures packets from a network device on linux and stores 
transfer stats on each host seen. To store the stats long term I decided to 
use sqlite, and when the program saves the stats every few minutes, it takes 
about 4-5 seconds, and if I have the synchronous pragma turned off, it takes 
1-2 seconds.

These are the relevant sql commands:

CREATE TABLE hosts (id INTEGER PRIMARY KEY,\
  address INTEGER UNIQUE, \
  first_seen INTEGER DEFAULT CURRENT_DATETIME, \
  last_on INTEGER DEFAULT CURRENT_DATETIME, \
  last_off INTEGER, \
  rx_bytes INTEGER, \
  tx_bytes INTEGER);

UPDATE hosts SET last_on = ?, last_off = ?, rx_bytes = ?, tx_bytes = ? WHERE id 
= ?
INSERT INTO hosts ( address, first_seen, last_on, rx_bytes, tx_bytes ) VALUES ( 
?, ?, ?, ?, ? )

The stats saving code will interleave a bunch of UPDATEs and INSERTs, inside a 
single transaction, maybe that has something to do with it, I'm not sure.

1s to update them all isn't too bad, but it still can mean I'm potentially 
dropping packets, which I'd really rather not do.

Thanks.

-- 
Thomas Fjellstrom
tfjellst...@strangesoft.net
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to