Jump to content

smishra

Members
  • Posts

    17
  • Joined

  • Last visited

Blog Comments posted by smishra

  1. How can mysql perform a fast query for an object within a range of an X/Z position? Y position can be ignored, since most games don't have much of a vertical component. I have tried for a long time to think of a way to sort objects in two dimensions, but it doesn't seem possible without putting them into some kind of grid structure.

     

    One way may be to perform two queries

     

    1. fast, simple query to eliminate impossible objects where

     

    x_any_object - x_ref > range

     

    and

     

    z_any_object - z_ref > range

     

    The results of this can be stored in a temporary, in memory table and then used to run the second query

     

    2. Of the smaller set of objects that are left perform

     

    ((x_any_object - x_ref) * (x_any_object - x_ref) +

    (z_any_object - z_ref) * (z_any_object - z_ref)) < range * range

     

     

    A custom, hand optimized implementation of data structures and implementation will always be faster than something built on a general abstraction like a database layer.

     

    The question is the amount of time available for data structure specific optimization versus the general features brought in by a DB layer like sqlite

     

    ---------------------

     

    3. Of course if these are common functions, one would eventually expect custom hardware to support this function. Wait this is what graphics cards do. :-) Maybe a better chipset/GPU architecture might help these sort of computations!

×
×
  • Create New...