dsfliu1129 2012-04-13 14:13
浏览 28
已采纳

很多小的sql语句会大大减慢我的网站速度

I have a zen-cart with 25-30 categories. On the front page of the site each category will get it's own little area in which the 4 best selling products in that category will be displayed.

Being a bit of a noob the best way I can think of doing this is to have a single sql statement for each category which picks out the best sellers each time the page loads. I've read somewhere that you're best to limit the amount of sql statements so as not to affect site speed.

Would doing it this way be very much slower?

Is there a more sensible way of doing this?

  • 写回答

1条回答 默认 最新

  • doucong3048 2012-04-13 14:20
    关注

    That highly depends on the server backing your website. But 25 to 30 queries shouldn't have a major impact on the page performance.

    A better way would be to design a database query that fetches all the items with one query. But to help you doing so we'd need the schema of your database.

    Also in case you have to do many similar queries there is the options to use "prepared queries" that usually speed up the performance a good bit.

    After all generally speaking, if you are new to working with database, its often better to design a few more small queries that are easily structures and can be handled by you, then one large query that has the potential to contain errors and maybe slows the database down more then then multiple small queries.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了
  • ¥100 H5网页如何调用微信扫一扫功能?
  • ¥15 讲解电路图,付费求解
  • ¥15 有偿请教计算电磁学的问题涉及到空间中时域UTD和FDTD算法结合的
  • ¥15 three.js添加后处理以后模型锯齿化严重