Giter VIP home page Giter VIP logo

Comments (2)

davidlublink avatar davidlublink commented on May 17, 2024

Add the following columns and indexes ( MySQL ) to your sip_capture table :

resu_ot varchar(100) NOT NULL DEFAULT '',
resu_morf varchar(100) NOT NULL DEFAULT '',
KEY resu_morf (resu_morf),
KEY resu_ot (resu_ot)

Run the following in your database :
DELIMITER |
Create Trigger reverse_field Before insert on sip_capture
FOR EACH ROW
BEGIN
set NEW.resu_ot = reverse( NEW.to_user);
set NEW.resu_morf = reverse( NEW.from_user );
END;
|
DELIMITER ;

And apply the following patch :
diff --git a/webhomer/DataTable/sip/SipSearchService.php b/webhomer/DataTable/sip/SipSearchService.php
index e41ec68..0e41f53 100644
--- a/webhomer/DataTable/sip/SipSearchService.php
+++ b/webhomer/DataTable/sip/SipSearchService.php
@@ -129,7 +131,15 @@ class SipSearchService implements ISipService
if(!isset($callwhere)) $callwhere = "(";
if($key == "callid" && $b2b ) $callwhere.=" (";

  •    if ( in_array( $key, arraY('from_user', 'to_user' )) && $value[0] === '%' )
    
  •    {
    
  •         $key = strrev( $key );
    
  •         $value = strrev( $value );
    
  •    }
    
    • $eqlike = preg_match("/%/", $value) ? " like " : " = ";
        if(preg_match("/^!/", $value)) {
            $value =  preg_replace("/^!/", "", $value);
    

Here is the patch as a base64 :

ZGlmZiAtLWdpdCBhL3dlYmhvbWVyL0RhdGFUYWJsZS9zaXAvU2lwU2VhcmNoU2VydmljZS5waHAg
Yi93ZWJob21lci9EYXRhVGFibGUvc2lwL1NpcFNlYXJjaFNlcnZpY2UucGhwCmluZGV4IGU0MWVj
NjguLjBlNDFmNTMgMTAwNjQ0Ci0tLSBhL3dlYmhvbWVyL0RhdGFUYWJsZS9zaXAvU2lwU2VhcmNo
U2VydmljZS5waHAKKysrIGIvd2ViaG9tZXIvRGF0YVRhYmxlL3NpcC9TaXBTZWFyY2hTZXJ2aWNl
LnBocApAQCAtMTI5LDcgKzEzMSwxNSBAQCBjbGFzcyBTaXBTZWFyY2hTZXJ2aWNlIGltcGxlbWVu
dHMgSVNpcFNlcnZpY2UKIAkgICBpZighaXNzZXQoJGNhbGx3aGVyZSkpICRjYWxsd2hlcmUgPSAi
KCI7CiAJICAgaWYoJGtleSA9PSAiY2FsbGlkIiAmJiAkYjJiICkgJGNhbGx3aGVyZS49IiAoIjsK
IAorICAgICAgICBpZiAoIGluX2FycmF5KCAka2V5LCBhcnJhWSgnZnJvbV91c2VyJywgJ3RvX3Vz
ZXInICkpICYmICR2YWx1ZVswXSA9PT0gJyUnICkKKyAgICAgICAgeworICAgICAgICAgICAgICRr
ZXkgPSBzdHJyZXYoICRrZXkgKTsKKyAgICAgICAgICAgICAkdmFsdWUgPSBzdHJyZXYoICR2YWx1
ZSApOworICAgICAgICB9CisKIAkgICAkZXFsaWtlID0gcHJlZ19tYXRjaCgiLyUvIiwgJHZhbHVl
KSA/ICIgbGlrZSAiIDogIiA9ICI7CiAgICAgIAogICAgICAgICAgICBpZihwcmVnX21hdGNoKCIv
XiEvIiwgJHZhbHVlKSkgewogICAgICAgICAgICAgICAgJHZhbHVlID0gIHByZWdfcmVwbGFjZSgi
L14hLyIsICIiLCAkdmFsdWUpOwo=

On the tested machine, the search time for a query prefixed with % took several minutes. With the patch, it took less than 2 seconds. Test machine had 70,000,000 rows in the table.

from homer.

adubovikov avatar adubovikov commented on May 17, 2024

Thanks for the patch, but we couldn't accept it.
first, you should understand if you use % (wildcard) as prefix, mysql don't use index at all and make full scan on the table/tables and of course it takes a lot time (depends how much records you have).
second, to avoid such behavior, better use predefined prefixes and MYSQL SQL query with "IN (array)" i.e. (123456 will search +123456, 00123456, 023456 etc)
such query will use index and will be more effective than use reverse value and create additional two indexes.

btw, please use Homer5. There we use more effective sql schema and design.

from homer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.