On 25 Mar 2017, at 10:52pm, petern <peter.nichvolo...@gmail.com> wrote:

> CREATE TABLE cmd(opcode TEXT, params TEXT);
> 
> Also assume each reader is in a different process which maintains its own
> open db connection over which it periodically executes the following
> command retrieval query,
> 
> SELECT * FROM cmd WHERE rowid>=$lastCmdRowid;

I presume you mean '>' not '>='.

Not answering your question, but making some recommendations.  If the order of 
commands matters, then you might use this instead:

SELECT * FROM cmd WHERE rowid > $lastCmdRowid ORDER BY rowid;

Since you have a polling loop, you might want to make that as efficient as 
possible.  Possibly the quickest way to do it would be

SELECT max(rowid) FROM cmd;

then do the comparison in your code.  If and only if the new value is bigger 
you do the other SELECT.

Since you intend to make use of the rowid column, it’s best to make that 
explicit in your code.  I know SQLite understands the reference anyway, but 
you’re also explaining things to anyone reading your code.

CREATE TABLE cmd(id INTEGER PRIMARY KEY, opcode TEXT, params TEXT);

Given your requirements I recommend that you put this database into WAL mode.

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to