0
를 사용하여 수정 1000 엔티티
여기 내 원래의 질문에 제안 지그 만델로, 태스크 큐를 사용하여 1000 개체를 수정 바라고 :구글 앱 엔진 : 작업 대기열
Google App Engine: Modifying 1000 entities 내가 종류의이 같은 UserAccount 있습니다
class UserAccount(ndb.Model):
email = ndb.StringProperty()
UserAccount email
의 일부 는 uppercases (예 : [email protected])를 포함, 나는 모든 기업의 이메일에 email.lower()
을 적용하고 싶습니다.
class LowerEmailQueue(BaseHandler):
def get(self):
all_accounts = UserAccount.query().fetch()
for a in all_accounts:
taskqueue.add(url = '/lower-email', params = {'account_id': a.key.id()})
class LowerEmail(BaseHandler):
def post(self):
account_id = self.request.get('account_id')
account = UserAccount.get_by_id(int(account_id))
account.email = account.email.lower()
account.put()
app = webapp2.WSGIApplication([
('/', MainPage),
('/lower-email-queue', LowerEmailQueue),
('/lower-email', LowerEmail),
], debug=True)
. 이게 효과가 있니?
좋은 얼룩 무늬 다니엘. 감사합니다. 이 변화를 가정하면 효과가 있습니까? 나는 커서가 관련되어야한다고 들었다. – puoyaahhh
이제는 작동하지만 잔인 함은 항목 당 하나의 작업 대기열을 사용합니다. 최소한 작업 대기열 당 50 개를 수행하십시오. 실제로는 커서를보아야합니다 –
최소한 루프는 작은 배열 (예 : 20 개 항목)을 구성하고 배열을 문자열로 바꾸고 작업 대기열 매개 변수로 전달할 수 있습니다. 커서가 최적의 방법 일 것이기 때문에 커서를 언급했습니다. 쿼리는 루프가 아닌 각 작업 대기열에 의해 만들어졌습니다. 프론트 엔드 인스턴스에서 루프가 시간 초과되는 항목이 더 많습니다. –