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

  • Home
  • SEARCH
  • 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 6650005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:50:31+00:00 2026-05-26T00:50:31+00:00

The first query works just fine. It returns one row from the table ‘routepoint’.

  • 0

The first query works just fine. It returns one row from the table ‘routepoint’. It has a certain ‘route_id’ and ‘geo_distance()’ is on its minimum given the parameters. I know that the subquery in the FROM section seems unnecessarily complicated but in my eyes it helps to highlight the problem with the second query.

The differences are in the last two rows.

SELECT rp.*

FROM routepoint rp, route r, (SELECT * FROM ride_offer WHERE id = 6) as ro

WHERE rp.route_id = r.id
AND r.id = ro.current_route_id
AND geo_distance(rp.lat,rp.lng,52372070,9735690) = 

(SELECT MIN(geo_distance(lat,lng,52372070,9735690)) 
FROM routepoint rp1, ride_offer ro1 
WHERE rp1.route_id = ro1.current_route_id AND ro1.id = 6);

The next query does not work at all. It completely freezes mysql and I have to restart.
What am I doing wrong? The first subquery returns excactly one row. I don’t understand the difference.

SELECT rp.*

FROM routepoint rp, route r, (SELECT * FROM ride_offer WHERE id = 6) as ro

WHERE 
rp.route_id = r.id
AND r.id = ro.current_route_id
AND geo_distance(rp.lat,rp.lng,52372070,9735690) = 

(SELECT MIN(geo_distance(lat,lng,52372070,9735690)) 
FROM routepoint rp1 
WHERE rp1.route_id = ro.current_route_id);
  • 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-26T00:50:31+00:00Added an answer on May 26, 2026 at 12:50 am

    The problem is, as pointed out by Romain, that this is costly.

    This article describes an algorithm that reduces the cost by a 2-step process.

    Step 1: Find a bounding box that contains at least one point.

    Step 2: Find the closest point by examining all points in the bounding box, which should be a comparatively small number, thus not so costly.

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

Sidebar

Related Questions

First, from BOL : Queries that modify table variables do not generate parallel query
I can't display the first entry from my query that returns multiple answers. For
I created the following script to query a table and return the first 30
I have a performance problem on a query. First table is a Customer table
Basically I have a search query, which works fine if I'm using it with
I need to create a view or a table valued function that returns one
I'm running a query that is timing out for first two times and returning
With :limit in query, I will get first N records. What is the easiest
I am trying to use an update query to update the first 3 characters
I'm trying to set up a query that shows the first post of each

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.