dongming4994 2013-12-24 11:26
浏览 27

500内部服务器错误 - PHP

I am running the 1 website on my server. That website has a search facility.

When I search for a category named "apple" at that time its showing 10 results and I am getting search result page fine and fast. [RECORDS ARE PAGINATED 10 records per page]

Now, When I search for "orange" named category at that time its giving me an internal server 500 error. It's just because it's trying to pull 300000 records from the database. [After 2 mins I am getting this error on page]

So How can I resolve this issue? I have checked queries too and its all fine. I need to record faster with no errors like internal server.

Is there any way to resolve this?

Please help! Thank you....

  • 写回答

2条回答 默认 最新

  • dqqpf32897 2013-12-24 11:39
    关注

    Use LIMIT in your database queries to get only the number of rows you need, for example this will select the first 10 rows :

    SELECT * FROM "table" WHERE something = "something" LIMIT 10
    

    And you can also use an offset, this will select 10 rows from the 5th row :

    SELECT * FROM "table" WHERE something = "something" LIMIT 5,10
    

    More information in the official MySQL documentation.

    If you need the total number of rows you can use COUNT :

    SELECT COUNT(*) FROM "table" WHERE something = "something"
    
    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line