Jump to content

Optimize query


jaymc

Recommended Posts

I have a cron job execute a script every 1 minute

 

That script queries a table and drags out 15,000 rows, and for each row then executes another query on updating a table

 

So thats basically 15,000 queries..

 

Its killing the server when it runs and locking mysql quite heavily

 

Rather than have 15,000 seperate queries I was think of using 1 query and structuring it as so

 

WHERE IN ID (1,2,3,4,5,6,7.......15,000)

 

A whopping single query, but could it cope with 15,000 'IN IDs' and would it be better than just having 15,000 single queries

Link to comment
Share on other sites

What if I use the in ID method with 700 entreies rather than 15,000

 

Would that be fine?

 

Ive actually thought of a way to reduce the rows your see

 

So basically

 

WHERE IN ID(1,2,3,4,5,6,7,8....700)

Link to comment
Share on other sites

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.