faster tag updating for large number of tags

This commit is contained in:
Damien Elmes 2010-08-16 18:52:55 +09:00
parent 1f90eceaec
commit 84cb81854b

View file

@ -1750,15 +1750,9 @@ facts.modelId = :id""", id=modelId))
insert into cardTags insert into cardTags
(cardId, tagId, src) values (cardId, tagId, src) values
(:cardId, :tagId, :src)""", d) (:cardId, :tagId, :src)""", d)
tags = self.s.column0("select id from tags") self.s.execute(
unused = [] "delete from tags where priority = 2 and id not in "+
for t in tags: "(select distinct tagId from cardTags)")
if not self.s.scalar(
"select 1 from cardTags where tagId = :d limit 1",
d=t):
unused.append(t)
self.s.statement("""
delete from tags where id in %s and priority = 2""" % ids2str(unused))
def updateTagsForModel(self, model): def updateTagsForModel(self, model):
cards = self.s.all(""" cards = self.s.all("""