douti8321 2013-10-11 09:20 采纳率: 0%
浏览 5
已采纳

关联变量及其ID的最佳方法

I am getting results from a database with a simple php while loop, one of the pieces of information is a number that links to another table where the value is stored, I can think of plenty of ways to get this information linked and display the text related to the value but I want to know the fastest way to do it as I have a huge set of results so every bit of speed will make a difference. Is an array fastest, javascript? any advice you can give me would be great.

The schema would look something like this

col_table 
colID(autonumber) colName(str) colState(int) colDate(date) 

state_table
stateID(int) stateType(str)

I want to select the correct state type based on the colState matching a stateID and output the stateType while preserving the stateID for so I can edit the field and update the database using the number.

  • 写回答

3条回答 默认 最新

  • doujiao4705 2013-10-11 09:52
    关注

    Using MySQL will be faster. If you have to get through a PHP loop to read your results and make each time a new MySQL request, your script will take longer.

    You can increase speed on MySQL by creating the right kind/amount of index, choosing wisely what is store in each field.

    The later you parse content, the longer it will take. If you go for js, you will have to read a DB, loop trough it in PHP and do it again in JS, and making more request again ...

    A join can be a good solution. A view can be even more easier to treat. Yuo can also consider caching results

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥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