Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Optimization

  1. #1
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,959
    Thanks
    120
    Thanked 76 Times in 76 Posts

    Optimization

    d.la & t.term are same size & type
    d.la is key on table
    t.term is part of index on table t

    Code:
    EXPLAIN EXTENDED
     select  distinct la ,REPLACE(UUID(),'-','') as id_tezaver_obfuscated, grupa 
    	 from _test_uvozi_v_tezaver_lang_2_not_delimited d
    	 left join tezaver t on d.la = t.term and t.l2 = 'la' 
    	 where t.term is null
    Code:
    "1"	"SIMPLE"	"d"	"ALL"	"N"	"N"	        "N"     "N"      "1498"	        "100,00"	"Using temporary"
    "1"	"SIMPLE"	"t"	"index"	"N"	"Index 3"	"621"	""	 "767327"	"100,00"	"Using where; Using index; Not exists; Distinct"
    If I cut ",REPLACE(UUID(),'-','') as id_tezaver_obfuscated, grupa " of, the index on d table gets used, but whole thing is not faster.
    It takes 20 sec + ....

    Can this be optimized ?
    Last edited by BubikolRamios; 10-16-2013 at 08:38 PM.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    New Coder
    Join Date
    Oct 2013
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You generate a random UUID for every record and you use DISTINCT on the outcome, that's never going to be fast.

    Given that theprinciple of a UUID is that it's always unique anyway and that the UUID is not linked in any way to the actual record, you might as wel leave it out.

  • #3
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,959
    Thanks
    120
    Thanked 76 Times in 76 Posts
    except minus "Using temporary" on first row & minus "distinct "on second row of EXPLAIN EXTENDED, by your recipe, nothing changes. Stil 20 + seconds (break execution after that)

    Code:
    "1"	"SIMPLE"	"d"	"ALL"	"N"	"N"	        "N"     "N"      "1498"	        "100,00"	"N"
    "1"	"SIMPLE"	"t"	"index"	"N"	"Index 3"	"621"	""	 "767327"	"100,00"	"Using where; Using index; Not exists;"
    Last edited by BubikolRamios; 10-16-2013 at 09:18 PM.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #4
    New Coder
    Join Date
    Oct 2013
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are the colums mentioned in the JOIN included in indexes?

  • #5
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,959
    Thanks
    120
    Thanked 76 Times in 76 Posts
    They are, but as part of combination of columns per index.

    I added new index on table t adding only t.term column.

    now it flys with speed of light

    Code:
    "1"	"SIMPLE"	"d"	"ALL"	"N"	        "N"	        "N"	"N"	        "1498"	"100,00"	"Using temporary"
    "1"	"SIMPLE"	"t"	"ref"	"Index 5"	"Index 5"	"602"	"test.d.la"	"1"	"100,00"	"Using where; Not exists; Distinct"
    What does ref "test.d.la" in upper explain means, where does "test" comes from ?
    Last edited by BubikolRamios; 10-16-2013 at 09:31 PM.
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,023
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    You say term is PART of the index on table t.

    What does the FULL index look like?

    Maybe show us the results of SHOW CREATE TABLE tezaver
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •