CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Best tech approach for large inserts: MySQL or CiviCRM API?
Pages: [1]

Author Topic: Best tech approach for large inserts: MySQL or CiviCRM API?  (Read 1036 times)

kung

  • I’m new here
  • *
  • Posts: 17
  • Karma: 0
  • CiviCRM version: 5
  • CMS version: Drupal 6 or 7
  • MySQL version: 5
  • PHP version: 5
Best tech approach for large inserts: MySQL or CiviCRM API?
February 21, 2012, 02:47:04 pm
I have to do an initial migration of 300K contacts into CiviCRM.  I've sketched out two possible approaches: a series of MySQL inserts and a chained API call (it will include custom fields).
I'm sure many people have faced this question.  What's the verdict? Which approach is better?  I'll be using the API for ongoing upserts, but I'm perplexed about the initial migration.
Thanks.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Best tech approach for large inserts: MySQL or CiviCRM API?
February 21, 2012, 03:17:32 pm
You may want to read about our explorations of using the Migrate module here - http://fuzion.co.nz/content/migrate-2-civicrm-api-3-civimigrate

It has worked well for us in pulling in large and complex legacy systems HTH
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

kung

  • I’m new here
  • *
  • Posts: 17
  • Karma: 0
  • CiviCRM version: 5
  • CMS version: Drupal 6 or 7
  • MySQL version: 5
  • PHP version: 5
Re: Best tech approach for large inserts: MySQL or CiviCRM API?
February 21, 2012, 03:37:44 pm
Very interesting.  I really like the way you're involving the Drupal module.  I'm going to give this a try.  I'll report back.
Thanks.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Best tech approach for large inserts: MySQL or CiviCRM API?
February 21, 2012, 11:52:56 pm
Hi,

It will obviously run faster if you stay as close as possible to the metal and you go directly into the db. This being said, the api overhead is there to hide the complexity of the sql schema and will likely avoid a lot of problems of corrupted and incoherent data. I'd recommend using the API, 300k isn't that much.

We have identified a few apis (email and phone for instance if I recall) that that are overly protective and do an extra read to verify that the type is valid. This additional lookup is costly when you do it for each. On that topic, try to use ids for these type of fields (status, role, type...) to avoid an extra query (often), and do the mapping manually ones at the start.

I would suggest you to ping us on IRC and help fixing them, the time you spend improving the API will save a lot of time.

It's probably not worthwhile chaining the api in php code, write separate calls, allows a finer error handling.

I personally prefer stating away of any UI for my imports, because having to clicks around is way slower i feels than having everything in code. Last but not the least, have a look at api/class.api.php it offers the same feature but with a different syntax that I grew found of recently.

X+


-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Best tech approach for large inserts: MySQL or CiviCRM API?

This forum was archived on 2017-11-26.