Django Web开发 ,我有一个很简单的查询,可数据有几十万条,查询出来很慢,我有分页,怎么提高效率问题 20
defadminSamplelist(request):RulelistAll=RuleList.objects.order_by('rule_id').filter(q...
def adminSamplelist(request):
RulelistAll = RuleList.objects.order_by('rule_id').filter(querylist).all()
if request.GET.get('export') == '1':
return Export_syslog(querylist)
after_range_num = 2
before_range_num = 9
try:
page = int(request.GET.get('page',1))
if page < 1:
page = 1
except ValueError:
page = 1
paginator = Paginator(RulelistAll,12)
try:
RulelistAllList = paginator.page(page)
except(EmptyPage,InvalidPage,PageNotAnInteger):
RulelistAllList = paginator.page(1)
for date in RulelistAllList.object_list:
date['lastupdate'] = str(date['lastupdate'])[:10]
if page >= after_range_num:
page_range = paginator.page_range[page - after_range_num:page + before_range_num]
else:
page_range = paginator.page_range[0:int(page) + before_range_num]
return render_to_response('Rule_list.html', locals()) 展开
RulelistAll = RuleList.objects.order_by('rule_id').filter(querylist).all()
if request.GET.get('export') == '1':
return Export_syslog(querylist)
after_range_num = 2
before_range_num = 9
try:
page = int(request.GET.get('page',1))
if page < 1:
page = 1
except ValueError:
page = 1
paginator = Paginator(RulelistAll,12)
try:
RulelistAllList = paginator.page(page)
except(EmptyPage,InvalidPage,PageNotAnInteger):
RulelistAllList = paginator.page(1)
for date in RulelistAllList.object_list:
date['lastupdate'] = str(date['lastupdate'])[:10]
if page >= after_range_num:
page_range = paginator.page_range[page - after_range_num:page + before_range_num]
else:
page_range = paginator.page_range[0:int(page) + before_range_num]
return render_to_response('Rule_list.html', locals()) 展开
4个回答
2011-09-24
展开全部
dim rs as adodb.recordset
dim conn as adodb.connection //must open conn before the form show
dim sqlstr as string
sqlstr = "select * from table"
set rs = conn.execute(sqlstr)
if rs.eof then exit sub
grid.rows = grid.rows +1
grid.textmatirs(grid.rows-1,1) = rs.fields(0)
grid.textmatirs(grid.rows-1,2) = rs.fields(1)
......
grid.textmatirs(grid.rows-1,n) = rs.fields(n)
我不知道你要查询的记录集有几个字段,所以用n表示。
懂了吗?
dim conn as adodb.connection //must open conn before the form show
dim sqlstr as string
sqlstr = "select * from table"
set rs = conn.execute(sqlstr)
if rs.eof then exit sub
grid.rows = grid.rows +1
grid.textmatirs(grid.rows-1,1) = rs.fields(0)
grid.textmatirs(grid.rows-1,2) = rs.fields(1)
......
grid.textmatirs(grid.rows-1,n) = rs.fields(n)
我不知道你要查询的记录集有几个字段,所以用n表示。
懂了吗?
追问
我没明白你这是什么意思,Django框架中,我没有写Sql语句的,请在我的那个查询View里面改,感谢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
.........................
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不懂哦
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把你分页的查询语句发上来。
追问
出来了?帮忙看看吧
追答
建议你在数据库中分页。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询