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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    optimization frustration!

    for some reason, this isnt working too well.

    PHP Code:
    Array ( [0] => [id] => [1] => SIMPLE [select_type] => SIMPLE [2] => chat [table] => chat [3] => range [type] => range [4] => reciever,type,postedby [possible_keys] => reciever,type,postedby [5] => type [key] => type [6] => 255 [key_len] => 255 [7] => [ref] => [8] => 5552 [rows] => 5552 [9] => Using whereUsing filesort [Extra] => Using whereUsing filesort 
    is what im getting when i explain my query, it consist of a couple or's and and's

    PHP Code:
      $mychat="EXPLAIN SELECT * from chat where type='chest'";
     
    $mychat .=" OR type='auction' AND postedby='Admin'";
     
    $mychat .=" OR type='mutes' AND reciever='$player'";
     
    $mychat .=" OR type='tomutes' AND reciever='$player'";

    $mychat .=" order by ID DESC LIMIT 50";
          
    $mychat2=mysql_query($mychat) or die("Chat Error: 4052");
          
    $mychat3=mysql_fetch_array($mychat2); 
    I have type and reciever and ID and postedby all indexed, theres 20,000 rows and its searching 5000 so its semi working...but i need to get that down even more...any ideas?

  • #2
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    would putting the indexes on (type,postedby) and (type,receiver) maybe help?

  • #3
    Regular Coder
    Join Date
    Jul 2005
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by GJay
    would putting the indexes on (type,postedby) and (type,receiver) maybe help?
    ha genious :P went from a couple thoughsand rows to a couple hundred thanks

  • #4
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    OK smarty pants Try this one on for size

    Code:
    SELECT 
    	MAX(tblairports.fldResort) AS ap_destname, 
    	IFNULL(tblairports.fldResort, tbloffers.fldDestination) AS dest_name, 
    	fldDestinationAPC, 
    	MAX(fldAPName), 
    	MIN(fldPrice) AS price, 
    	MAX(fldCountry) AS country, 
    	fldBoardBasis, MAX(fldFlyingTime) AS fldFlyingTime, 
    	COUNT(fldOfferID) AS offercount 
    FROM 
    	tbloffers 
    RIGHT JOIN 
    	tblClients
    ON
    	tblClients.fldClientID=tbloffers.fldClientID 
    LEFT JOIN 
    	tblairports 
    ON 
    	fldDestinationAPC=fldAPCode 
    WHERE 	
    	NOT fldExclude 
    	AND fldDepartureDate >= '2006-10-01' 
    	AND fldDepartureDate <= '2006-10-11' 
    	AND (tblairports.fldResort='Turkey' OR tblairports.fldCountry='Turkey' OR tbloffers.fldDestination='Turkey') 
    	AND tbloffers.fldSearchTypes = 'all, med/europe/canaries' 
    GROUP BY 
    	dest_name, fldBoardBasis 
    ORDER BY 
    	price
    Code:
     id  	 select_type  	 table  	 type  	 possible_keys  	 key  	 key_len  	 ref  	 rows  	 Extra
    1 	SIMPLE 	tbloffers 	range 	fldClientID_2,fldClientID,fldSearchTypes,fldDepart... 	fldDepartureDate 	3 	NULL 	253328 	Using where; Using temporary; Using filesort
    1 	SIMPLE 	tblClients 	eq_ref 	PRIMARY 	PRIMARY 	4 	icelolly_dev.tbloffers.fldClientID 	1 	Using where
    1 	SIMPLE 	tblairports 	eq_ref 	PRIMARY 	PRIMARY 	3 	icelolly_dev.tbloffers.fldDestinationAPC 	1 	Using where

  • #5
    Regular Coder
    Join Date
    Jul 2005
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts
    woah, that one might need a new thread :P you know how its in a table, does it display like that or you made it that way, ive been using print_r but tis a pain to read

  • #6
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Wrap print_r in <pre> tags and it makes it very readable.

    PHP Code:
    print "<pre>\n";
    print_r($blah);
    print 
    "</pre>\n"

  • #7
    Regular Coder
    Join Date
    Jul 2005
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fumigator View Post
    Wrap print_r in <pre> tags and it makes it very readable.

    PHP Code:
    print "<pre>\n";
    print_r($blah);
    print 
    "</pre>\n"


    ahhh of course thanks! *bows*


  •  

    Posting Permissions

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