zoukankan      html  css  js  c++  java
  • python-项目流程分析及优化查询方法

    项目流程分析:  ******

    1. 需求分析 2. 知识点 - 插件 3. 功能分析: - 用户登录 - session - 签名cookie PS: 主动设置超时时间:request.session.set_expiry(60 * 60 * 24 * 30) - 判断用户是否已经登录 - 装饰器 - 中间件 - 功能 - 获取并显示数据 - 模板渲染 - 返回页面,ajax获取数据 - 发送数据 - Form表单提交 - Ajax提交 4. 数据库设计 5. 功能设计 - 页面 - 数据提交
    查询性能优化

    表结构: Room
    1 2 .. User: 1 .. 10000 Booking: user_id room_id time_id date 1 1 8:00 2017-11-11 1 2 8:00 2017-11-11 1 3 8:00 2017-11-11 1 4 8:00 2017-11-11 1 5 8:00 2017-11-11 # 需求:获取2017-11-11所有预定信息: 打印: 用户名称,会议室名称, 预定时间段 # 解决方案一:11次 bk = models.Booking.objects.filter(date=2017-11-11) for item in bk: print(item.time_id, item.room.caption, item.user.user) # 解决方案二:1次 select * from ... left join user ... join room bk = models.Booking.objects.filter(date=2017-11-11).select_related('user','room') for item in bk: print(item.time_id, item.room.caption, item.user.user) # 解决方案三:3次 select * from booking where date=2017-11-11 select * from user where id in [1,] select * from room where id in [1,2,3,4,5] bk = models.Booking.objects.filter(date=2017-11-11).prefetch_related('user','room') for item in bk: print(item.time_id, item.room.caption, item.user.user)
  • 相关阅读:
    springcloud随便写点
    简单的数组排序
    简单wait(),notify()方法
    热词
    mysql日期函数
    springboot和jsp,以及引入jquery
    用户,权限,角色的关系
    通过字节码获取到的方法
    数据库并发事物
    在spring的业务层获取request,response
  • 原文地址:https://www.cnblogs.com/liuwei0824/p/8027751.html
Copyright © 2011-2022 走看看