Jump to content

Recommended Posts

I have two tables of point data. The first main table has about 50,000 rows of data with values that represent the temperature for a grid point. I also have another table with about 25,000 rows of data. I'm trying to update the values from the second table into the first table for the closest point. Doing this using spatial functions in MYSQL would likely be slow, so I decided to do a spatial join in ArcGIS to give them relating ID's. As such, there are repeating id's from the second table in the first table as expected. This is because the grid spacing in the first (main) table is much smaller than the second table and there will be duplicate grid points with the same value...which is what I want. The only problem is, when I try to update the values by id = id, the query takes forever to complete. It seems as if its looping through each row for each time which seems very inefficient. 

 

Is there a better method for doing this?

UPDATE grid, hrdps_points SET grid.val=hrdps_points.value WHERE grid.hrdpsid = hrdps_points.id
Link to comment
https://forums.phpfreaks.com/topic/305688-efficient-mysql-join-or-update/
Share on other sites

Two things to try

 

1) Ensure you have indexes set up on those id columns?

 

Then

 

2) Rewrite the query using explicit joins

UPDATE grid
    INNER JOIN 
    hrdps_points
       ON grid.hrdpsid = hrdps_points.id
SET
    grid.val = hrdps_points.value
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.