What takes less time

Discussion in 'PHP' started by roice, Nov 14, 2011.

  1. #1
    Hello,

    What takes less time for the server: to find if some variable content exist in small DB (20 rows/records) or if some seesion content is a number/ string using the ctype_digit function
    ?

    Thanks,
    Roi.
     
    roice, Nov 14, 2011 IP
  2. amgadhs

    amgadhs Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    My guess is using a session variable will be faster because you will access a value in memory instead of opening a database connection and retrieving the value from a table. Hope that answers your question.
     
    amgadhs, Nov 14, 2011 IP
  3. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #3
    Sessions should be faster, however, the speed between the 2 will most likely be negligible. If you're really concerned, do a benchmark of each. Qrite a quick script to run each 1000 times, and then run each loop 10 times and compare the averages.
     
    jestep, Nov 14, 2011 IP