db model: introduce indexes for better performance
This commit is contained in:
parent
27a1305b2d
commit
e65168db55
2 changed files with 15 additions and 5 deletions
|
|
@ -90,6 +90,10 @@ create table if not exists antibot(
|
|||
);""", []):
|
||||
echo "antibot table already exists"
|
||||
|
||||
|
||||
db.exec sql"create index PersonStatusIdx on person(status);"
|
||||
db.exec sql"create index PostByAuthorIdx on post(thread, author);"
|
||||
|
||||
# -------------------- Search --------------------------------------------------
|
||||
|
||||
if not db.tryExec(sql"""
|
||||
|
|
|
|||
16
editdb.nim
16
editdb.nim
|
|
@ -4,10 +4,16 @@ import strutils, db_sqlite, ranks
|
|||
var db = open(connection="nimforum.db", user="postgres", password="",
|
||||
database="nimforum")
|
||||
|
||||
db.exec(sql("update person set status = ?"), $User)
|
||||
db.exec(sql("update person set status = ? where ban <> ''"), $Troll)
|
||||
db.exec(sql("update person set status = ? where ban like '%spam%'"), $Spammer)
|
||||
db.exec(sql("update person set status = ? where ban = 'DEACTIVATED' or ban = 'EMAILCONFIRMATION'"), $EmailUnconfirmed)
|
||||
db.exec(sql("update person set status = ? where admin = 'true'"), $Admin)
|
||||
when false:
|
||||
db.exec(sql("update person set status = ?"), $User)
|
||||
db.exec(sql("update person set status = ? where ban <> ''"), $Troll)
|
||||
db.exec(sql("update person set status = ? where ban like '%spam%'"), $Spammer)
|
||||
db.exec(sql("update person set status = ? where ban = 'DEACTIVATED' or ban = 'EMAILCONFIRMATION'"), $EmailUnconfirmed)
|
||||
db.exec(sql("update person set status = ? where admin = 'true'"), $Admin)
|
||||
else:
|
||||
db.exec sql"create index PersonStatusIdx on person(status);"
|
||||
db.exec sql"create index PostByAuthorIdx on post(thread, author);"
|
||||
db.exec sql"update person set name = 'cheatfate' where name = 'ka';"
|
||||
|
||||
|
||||
close(db)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue