Add a table to hold only the Symbols
to improve performance.
This commit is contained in:
@@ -31,7 +31,7 @@ module.exports = compress(async (req, res) => {
|
|||||||
if (func === "/getSymbols") {
|
if (func === "/getSymbols") {
|
||||||
console.log("Request for Symbols");
|
console.log("Request for Symbols");
|
||||||
const db = new Database('./quoteDBs/consolidated.sqlite3', { verbose: console.log });
|
const db = new Database('./quoteDBs/consolidated.sqlite3', { verbose: console.log });
|
||||||
const stmt = db.prepare("SELECT distinct Symbol FROM OptionQuotes order by 1");
|
const stmt = db.prepare("SELECT distinct Symbol FROM Symbols order by 1");
|
||||||
let allDates = stmt.all();
|
let allDates = stmt.all();
|
||||||
//console.log(JSON.stringify(allDates));
|
//console.log(JSON.stringify(allDates));
|
||||||
db.close();
|
db.close();
|
||||||
|
|||||||
@@ -2,4 +2,8 @@ CREATE TABLE IF NOT EXISTS "OptionQuotes"( "TimeStamp"DateTime DEFAULT CURRENT_T
|
|||||||
"Symbol" Text,
|
"Symbol" Text,
|
||||||
"Data" Text);
|
"Data" Text);
|
||||||
|
|
||||||
CREATE INDEX smbDaTi on OptionQuotes (Symbol,timestamp);
|
CREATE INDEX IF NOT EXISTS smbDaTi on OptionQuotes (Symbol,timestamp);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS "Symbols" (
|
||||||
|
"Symbol" TEXT UNIQUE
|
||||||
|
);
|
||||||
@@ -13,6 +13,10 @@ ls quoteStore_202*.sqlite3.gz | while read db; do
|
|||||||
sqlite3 /tmp/xx.sqlite3 'drop table OptionQuotes;'
|
sqlite3 /tmp/xx.sqlite3 'drop table OptionQuotes;'
|
||||||
sqlite3 /tmp/xx.sqlite3 'alter table tmp rename to OptionQuotes;'
|
sqlite3 /tmp/xx.sqlite3 'alter table tmp rename to OptionQuotes;'
|
||||||
sqlite3 /tmp/xx.sqlite3 '.dump OptionQuotes' | sqlite3 consolidated.sqlite3
|
sqlite3 /tmp/xx.sqlite3 '.dump OptionQuotes' | sqlite3 consolidated.sqlite3
|
||||||
|
|
||||||
|
echo filling symbols table
|
||||||
|
sqlite3 consolidated.sqlite3 'insert INTO Symbols select DISTINCT Symbol from OptionQuotes where OptionQuotes.Symbol not in (select Symbol from Symbols);'
|
||||||
|
|
||||||
echo deleting...
|
echo deleting...
|
||||||
rm /tmp/xx.sqlite3
|
rm /tmp/xx.sqlite3
|
||||||
mv $db processedDBs
|
mv $db processedDBs
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ find . -maxdepth 1 -name 'quoteStore_202*.sqlite3.gz' | while read db; do
|
|||||||
sqlite3 /tmp/xx.sqlite3 'drop table OptionQuotes;'
|
sqlite3 /tmp/xx.sqlite3 'drop table OptionQuotes;'
|
||||||
sqlite3 /tmp/xx.sqlite3 'alter table tmp rename to OptionQuotes;'
|
sqlite3 /tmp/xx.sqlite3 'alter table tmp rename to OptionQuotes;'
|
||||||
sqlite3 /tmp/xx.sqlite3 '.dump OptionQuotes' | sqlite3 consolidated.sqlite3
|
sqlite3 /tmp/xx.sqlite3 '.dump OptionQuotes' | sqlite3 consolidated.sqlite3
|
||||||
|
|
||||||
|
echo filling symbols table
|
||||||
|
sqlite3 consolidated.sqlite3 'insert INTO Symbols select DISTINCT Symbol from OptionQuotes where OptionQuotes.Symbol not in (select Symbol from Symbols);'
|
||||||
|
|
||||||
rm /tmp/xx.sqlite3
|
rm /tmp/xx.sqlite3
|
||||||
if [[ "$delete" == "1" ]]; then
|
if [[ "$delete" == "1" ]]; then
|
||||||
echo deleting...
|
echo deleting...
|
||||||
|
|||||||
Reference in New Issue
Block a user