Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7694899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:25:24+00:00 2026-05-31T21:25:24+00:00

I need to query my DB based on a range of two values which

  • 0

I need to query my DB based on a range of two values which are essentially two columns of type float in my database.

After doing some research, I narrowed down my options to implementing this with an algorithm using either:

  1. 2D Orthogonal range search
  2. k-d tree structure

Now I eliminated the 1st option because my data are clustered and hence it won’t be useful.

So I’m gonna need to use the k-d tree structure. But how? I’ve never done it and dont know where to start. I have a method in one of my controllers thats set up as a stub to retrieve the result of this search but the search itself is not implemented.

Im trying to get the systematic steps involved in creating this functionality. So far this is what I thought I would need to do, of but have no clue if it’s the right way to go.

  1. A k-d tree has to be constructed in memory from data in the DB. (But not sure when this should be done—either when rails starts up or when a request comes in?)

  2. When an update happens to the data, edit the tree and save the entire tree into the database

  3. Would there be any way to save the k-d tree data-structure in the DB itself without constructing it explicitely?

Also, I have googled around but wondering if anyone out there has any resources that they could recommend for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:25:25+00:00Added an answer on May 31, 2026 at 9:25 pm

    There’s a gem that we used in a previous project:

    https://rubygems.org/gems/kdtree

    There’s also a thread-safe fork of it:

    https://rubygems.org/gems/tupalo-kdtree

    Maybe look at that before implementing your own.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to query a database which is designed so what a NVARCHAR column
Ok I need to build a query based on some user input to filter
I need to schedule some items in a postgres query based on a requested
I need to write a select query that joins the tables based on a
I need to query a table for values given a string. The table is
I need to query the database to get the column names , not to
I need a query which can do the following operation. I have a table
I have a very big table with many columns. Values in some of the
I've got an sql query that pulls locations from a database based on coordinates
I need to build (and run) a query based on different of conditions. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.