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) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Quick Search auto-complete doesn't work after 3.2.3 -> 3.4.7 upgrade
Pages: [1]

Author Topic: Quick Search auto-complete doesn't work after 3.2.3 -> 3.4.7 upgrade  (Read 1846 times)

jbertolacci

  • I post occasionally
  • **
  • Posts: 54
  • Karma: 1
Quick Search auto-complete doesn't work after 3.2.3 -> 3.4.7 upgrade
December 14, 2011, 02:52:42 pm
After upgrading from 3.2.3 to 3.4.7 on a test server, the Quick Search auto-complete no longer works. It spins, but no data is returned. If I look at processes in the database I see a a number of "SELECT DISTINCT(id), data FROM..." that have been churning for minutes.

If show the full process and run one of the SELECTs by hand from the mysql command line, the query is taking 34+ seconds. Interestingly if I switch over to my production database the query takes just as long, but the auto-complete works fine in the 3.2.3 machine.

Has the Quick Search query changed from 3.2.3 to 3.4.7?

Any pointers on what I should look at next to help resolve this would be greatly appreciated.

mysql> show processlist;
+-------+-------+-----------+---------------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id    | User  | Host      | db            | Command | Time | State        | Info                                                                                                 |
+-------+-------+-----------+---------------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| 40230 | jason | localhost | dev1_civicrm  | Query   |    0 | NULL         | show processlist                                                                                     |
| 40433 | imba  | localhost | dev1_drupal   | Sleep   |  724 |              | NULL                                                                                                 |
| 40435 | imba  | localhost | dev1_civicrm  | Query   |  724 | Sending data | SELECT DISTINCT(id), data
FROM   (
        ( SELECT 0 as exactFirst, cc.id as id, CONCAT_WS( ' :: ' |
| 40436 | imba  | localhost | dev1_drupal   | Sleep   |  724 |              | NULL                                                                                                 |
| 40438 | imba  | localhost | dev1_civicrm  | Query   |  724 | Sending data | SELECT DISTINCT(id), data
FROM   (
        ( SELECT 0 as exactFirst, cc.id as id, CONCAT_WS( ' :: ' |
| 40439 | imba  | localhost | dev1_drupal   | Sleep   |  723 |              | NULL                                                                                                 |
| 40440 | imba  | localhost | dev1_civicrm  | Query   |  723 | Sending data | SELECT DISTINCT(id), data
FROM   (
        ( SELECT 0 as exactFirst, cc.id as id, CONCAT_WS( ' :: ' |
| 40441 | imba  | localhost | dev1_drupal   | Sleep   |  723 |              | NULL                                                                                                 |
| 40442 | imba  | localhost | dev1_civicrm  | Query   |  723 | Sending data | SELECT DISTINCT(id), data
FROM   (
        ( SELECT 0 as exactFirst, cc.id as id, CONCAT_WS( ' :: ' |
| 40443 | imba  | localhost | dev1_drupal   | Sleep   |  723 |              | NULL                                                                                                 |
| 40444 | imba  | localhost | dev1_civicrm  | Query   |  723 | Sending data | SELECT DISTINCT(id), data
FROM   (
        ( SELECT 0 as exactFirst, cc.id as id, CONCAT_WS( ' :: ' |
| 40445 | imba  | localhost | dev1_drupal   | Sleep   |  723 |              | NULL                                                                                                 |
| 40446 | imba  | localhost | dev1_civicrm  | Query   |  723 | Sending data | SELECT DISTINCT(id), data
FROM   (
        ( SELECT 0 as exactFirst, cc.id as id, CONCAT_WS( ' :: ' |
| 40448 | imba  | localhost | dev1_drupal   | Sleep   |  722 |              | NULL                                                                                                 |
| 40449 | imba  | localhost | dev1_civicrm  | Query   |  722 | Sending data | SELECT DISTINCT(id), data
FROM   (
        ( SELECT 0 as exactFirst, cc.id as id, CONCAT_WS( ' :: ' |
| 40450 | imba  | localhost | dev1_drupal   | Sleep   |  722 |              | NULL                                                                                                 |
| 40451 | imba  | localhost | dev1_civicrm  | Query   |  722 | Sending data | SELECT DISTINCT(id), data
FROM   (
        ( SELECT 0 as exactFirst, cc.id as id, CONCAT_WS( ' :: ' |
| 40452 | imba  | localhost | dev1_drupal   | Sleep   |  721 |              | NULL                                                                                                 |
| 40453 | imba  | localhost | dev1_civicrm  | Query   |  721 | Sending data | SELECT DISTINCT(id), data
FROM   (
        ( SELECT 0 as exactFirst, cc.id as id, CONCAT_WS( ' :: ' |
| 40454 | imba  | localhost | dev1_drupal   | Sleep   |  721 |              | NULL                                                                                                 |
| 40455 | imba  | localhost | dev1_civicrm  | Query   |  721 | Sending data | SELECT DISTINCT(id), data
FROM   (
        ( SELECT 0 as exactFirst, cc.id as id, CONCAT_WS( ' :: ' |
| 40456 | imba  | localhost | dev1_drupal   | Sleep   |  719 |              | NULL                                                                                                 |
| 40457 | imba  | localhost | dev1_civicrm  | Query   |  719 | Sending data | SELECT DISTINCT(id), data
FROM   (
        ( SELECT 0 as exactFirst, cc.id as id, CONCAT_WS( ' :: ' |

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Quick Search auto-complete doesn't work after 3.2.3 -> 3.4.7 upgrade
December 14, 2011, 03:04:08 pm
You can check what fields are searched on the autocompletes and fields are returns. Might be good to try to alter the config.

What is the sql query that runs exactly?

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

jbertolacci

  • I post occasionally
  • **
  • Posts: 54
  • Karma: 1
Re: Quick Search auto-complete doesn't work after 3.2.3 -> 3.4.7 upgrade
December 14, 2011, 03:15:56 pm
Good pointer, I'll check to see if the configs are the same, might account for the difference. Here is the full SELECT...

Code: [Select]
SELECT DISTINCT(id), data
FROM   (
        ( SELECT 0 as exactFirst, cc.id as id, CONCAT_WS( ' :: ', sort_name, email, city, ste.name ) as data, sort_name
          FROM   civicrm_contact cc LEFT JOIN civicrm_email eml ON ( cc.id = eml.contact_id AND eml.is_primary = 1 )  LEFT JOIN civicrm_address sts ON ( cc.id = sts.contact_id AND sts.is_primary = 1)   LEFT JOIN civicrm_state_province ste ON ( sts.state_province_id = ste.id  )
                 
                 
                  WHERE ( email LIKE 'bertolacci,' OR sort_name LIKE 'bertolacci,'  OR nick_name LIKE 'bertolacci,' )  AND cc.is_deleted = 0 
          LIMIT 0, 10 )
        UNION
        ( SELECT 1 as exactFirst, cc.id as id, CONCAT_WS( ' :: ', sort_name, email, city, ste.name ) as data, sort_name
          FROM   civicrm_contact cc LEFT JOIN civicrm_email eml ON ( cc.id = eml.contact_id AND eml.is_primary = 1 )  LEFT JOIN civicrm_address sts ON ( cc.id = sts.contact_id AND sts.is_primary = 1)   LEFT JOIN civicrm_state_province ste ON ( sts.state_province_id = ste.id  )
                 
                 
                  WHERE ( email LIKE 'bertolacci,%' OR sort_name LIKE 'bertolacci,%'  OR nick_name LIKE 'bertolacci,%' )  AND cc.is_deleted = 0 
          ORDER BY sort_name
          LIMIT 0, 10 )
       ) t
ORDER BY exactFirst, sort_name

jbertolacci

  • I post occasionally
  • **
  • Posts: 54
  • Karma: 1
Re: Quick Search auto-complete doesn't work after 3.2.3 -> 3.4.7 upgrade
December 14, 2011, 03:28:34 pm
So the  Global Settings > Search Settings look the same on both machines.

  • Auto wildcard - No (thought I don't think this impacts Quick Search)
  • Include emails - Yes
  • Include nicknames - Yes (we use this for org acronyms)
  • Autocomplete search contact - Contact, Email, City, State

jbertolacci

  • I post occasionally
  • **
  • Posts: 54
  • Karma: 1
Re: Quick Search auto-complete doesn't work after 3.2.3 -> 3.4.7 upgrade
December 19, 2011, 11:51:18 am
Looks like there have been some auto-complete changes, but I am not seeing the code changes tracked in FishEye so I can investigate further. Xavier this is your issue right?

http://issues.civicrm.org/jira/browse/CRM-6239

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Quick Search auto-complete doesn't work after 3.2.3 -> 3.4.7 upgrade
December 19, 2011, 12:34:24 pm
Hi,

This change is scheduled for 4.2 that's something different.

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

jbertolacci

  • I post occasionally
  • **
  • Posts: 54
  • Karma: 1
Re: Quick Search auto-complete doesn't work after 3.2.3 -> 3.4.7 upgrade
December 21, 2011, 02:34:15 pm
Ok, I think I have identified the source of the trouble. I found the sql in CRM/Contact/Page/AJAX.php. Looks like two separate issues have stepped on each other's toes a little. CRM-5954 identified unnecessary DISTINCTs and JOINs coupled with ORDER BY leading to the creation of temporary tables and of course taking more time. Here is the patched query after CRM-5954:

Code: [Select]
        $query = "
SELECT id, data
FROM (
   SELECT cc.id as id, CONCAT_WS( ' :: ', {$select} ) as data, sort_name
   FROM civicrm_contact cc {$from}
   {$aclFrom}
   {$additionalFrom}
   {$whereClause}
   LIMIT 0, {$limit}
     ) t
ORDER BY sort_name
";


CRM-7931 modify the autocomplete query to show any exact matches first and reintroduced the DISTINCT statement. The resulting temp tables that are created are breaking autocomplete in my install. Here is the query after CRM-7931:

Code: [Select]
         $query = "
SELECT DISTINCT(id), data
FROM   (
        ( SELECT 0 as exactFirst, cc.id as id, CONCAT_WS( ' :: ', {$select} ) as data, sort_name
          FROM   civicrm_contact cc {$from}
                 {$aclFrom}
                 {$additionalFrom} {$includeEmailFrom}
                 {$exactWhereClause}
          LIMIT 0, {$limit} )
        UNION
        ( SELECT 1 as exactFirst, cc.id as id, CONCAT_WS( ' :: ', {$select} ) as data, sort_name
          FROM   civicrm_contact cc {$from}
                 {$aclFrom}
                 {$additionalFrom} {$includeEmailFrom}
                 {$whereClause}
          ORDER BY sort_name
          LIMIT 0, {$limit} )
       ) t
ORDER BY exactFirst, sort_name
LIMIT    0, {$limit}
";


I'm going to roll the query back to the prior version to see if all is well, but does something need to be done to reconcile these two issues?

Some direct links...
http://issues.civicrm.org/jira/browse/CRM-5954
http://issues.civicrm.org/jira/browse/CRM-7931

alanpuccinelli

  • I’m new here
  • *
  • Posts: 6
  • Karma: 0
  • CiviCRM version: 3.4
  • CMS version: Drupal 6.22
  • MySQL version: 5.2
  • PHP version: 5.3.6
Re: Quick Search auto-complete doesn't work after 3.2.3 -> 3.4.7 upgrade
February 03, 2012, 04:57:41 pm
Did this ever get resolved? I'm on 3.4.7 too and I can't get AutoComplete to return results either? I tried rolling back to the 5954 code, but that didn't seem to do it for me either.

jbertolacci

  • I post occasionally
  • **
  • Posts: 54
  • Karma: 1
Re: Quick Search auto-complete doesn't work after 3.2.3 -> 3.4.7 upgrade
February 03, 2012, 08:47:33 pm
Rolling back the code did work for me.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Quick Search auto-complete doesn't work after 3.2.3 -> 3.4.7 upgrade

This forum was archived on 2017-11-26.