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) »
  • Civicrm Api and uery
Pages: [1]

Author Topic: Civicrm Api and uery  (Read 567 times)

Giorgoch

  • I’m new here
  • *
  • Posts: 5
  • Karma: 0
  • CiviCRM version: 4.3
  • CMS version: Drupal
  • MySQL version: 5.5
  • PHP version: 5.4
Civicrm Api and uery
November 20, 2014, 06:56:08 am
Hi there again ,

I have a question about API and SQLQuery.

So there is  an Api call that takes to long  and Apache/ngix  Mysql crushes.
I have about 1.000.000 contributions to calc with this Api , Apache/ngix  Mysql (so on )are   in no limit but it takes to long.

what i mean is how can i find out which tables  Api is using  so that if it's possible to replace it with a direct Query?
Api Explorer does not help me  or i don't think so does any one has any idea how can i make it faster.
or how can i make this Api go faster ?

Thanks

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Civicrm Api and uery
November 20, 2014, 12:43:43 pm
There's an option you can add to civicrm.settings.php, "define( 'CIVICRM_DEBUG_LOG_QUERY', 1 );", which will append queries to the log (files/civicrm/ConfigAndLog/CiviCRM*log*) Documentation exists is but is pretty brief -- http://wiki.civicrm.org/confluence/display/CRMDOC/Debugging+for+developers#Debuggingfordevelopers-SettingswhichmodifyCiviCRMbehaviorfordebugging

This will log a lot more than you're actually interested in. (For example "SET NAMES utf8" is called a billion times.) In the past, I've used this option plus a mix of (a) grep, (b) manual editing, and (c) hacking CRM_Core_Error::debug_query() to get more focused info about the queries passing through. You should try enabling CIVICRM_DEBUG_LOG_QUERY and see if you can find a way to use it.

If doing it again (for the purpose that you describe), I'd probably make some local-hacks (or possibly nice, reusable patches)  for CRM_Core_Error::debug_query(), e.g.

 * Write queries to a different place and use a more structured format (e.g. CSV: "$fh=fopen('/tmp/query.log'...); fputscv($fh,array(...));" ).
 * Make it possible to turn the logging on+off at runtime (so that we can log queries while executing a specific API call)

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Civicrm Api and uery
November 21, 2014, 05:16:45 pm
It looks to me like that log data has been sent through an HTML encoder. The 
 is probably some kind of new-line/return.

adixon

  • I post frequently
  • ***
  • Posts: 314
  • Karma: 19
    • Blackfly Solutions
Re: Civicrm Api and uery
November 23, 2014, 07:21:51 am
Any reason you don't try the mysql log slow query option?

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Civicrm Api and uery

This forum was archived on 2017-11-26.