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 8449749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:47:38+00:00 2026-06-10T10:47:38+00:00

So I have a notes field that is getting one row (assigned_user_id) updated to

  • 0

So I have a “notes” field that is getting one row (assigned_user_id) updated to new id’s. Notes is approx. 160k in length. The users table is around 300.

For each notes row I compare the assigned_user_id to the users table, if a match is found, get the new user ID and update the notes table. Rinse repeat:

//dis-allow timeout. Was timing out consistently under 100 rows changes.
set_time_limit(0);
ignore_user_abort(1);

//foreach note
$counter = 0;
foreach ( $msCRMAnnotations as $key=>$value)
{

    //foreach user, check for match between assigned_user_id and id_mscrm
    foreach( $sugarCRMUsers as $key2=>$value2 )
    {
        if($value['assigned_user_id'] == $value2['id_mscrm'] )
        {
            //give some output as to what is changing...
            echo("Note #"  . $counter++ . " - Note id " . $value['id'] . "  is assigned to user " . $value2['user_name'] . ".<br />" );

            $query = "
                UPDATE `notes`
                SET `assigned_user_id` = '" . $value2['id'] . "'
                WHERE `id` = '" . $value['id'] . "' AND
                `assigned_user_id` = '" . $value['assigned_user_id'] . "'
            ";
            $DB->query($query);
            //unset($query);
        }
    }
}

Specifically we are migrating select data from a MsCRM to SugarCRM. This being the accounts/notes/users phase of the project.

So now the question….how can I best re-factor the above code to be more performant? Any and all help is greatly appreciated.

  • 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-06-10T10:47:40+00:00Added an answer on June 10, 2026 at 10:47 am

    Assuming from comments:

    Try to set indexes for these columns, for faster search.

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

Sidebar

Related Questions

I have some Lotus Notes clients that looses server connection. They suddenly get server
my table(s) structure (MySQL / each one is same as below) +-------+--------------+------+------+-------------------+ | Field
I have a custom jQuery script that works fine in all bowsers but one
I have a LIST (query output)that has the distinct ID’s from a table Account.
I have a property in one of my models that is linked to a
I have a line of data that contains various non-delimited field values. X55655PlateX58745CupX52689SaucerX52459SpoonH59876KnifeX59866Fork I
I have a vector of objects (objects are term nodes that amongst other fields
I have a HTML form with fields such as name, address, notes, etc. I
I have notes attribute in Product model with text something, something else. In views
I have multiple notes with class=.note and unique id each inside a div. On

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.