MySQL Forums
Forum List  »  German

Re: Abfrage in einer Hierarchie
Posted by: Gerald Koch
Date: September 20, 2010 07:07AM

UUUUH du gott :-)

also wenn jetzt nix im cache war siehts gut aus....
das ist die tabelle:
CREATE TABLE `yp_ent_par_materialize` (
  `YP_INSTANCE_ID` int(11) NOT NULL,
  `YP_ENTITY_TYPE_ID` int(11) NOT NULL,
  `YP_PARAMETER_TYPE_ID` int(11) NOT NULL,
  `YP_PARAMETER_VALUE_STRING` varchar(64) NOT NULL,
  `PRIM_KEY` int(11) NOT NULL auto_increment,
  PRIMARY KEY  (`PRIM_KEY`),
  KEY `YP_ENT_PAR_MATERIALIZE_IDX0` (`YP_INSTANCE_ID`,`YP_ENTITY_TYPE_ID`,`YP_PARAMETER_VALUE_STRING`),
  KEY `YP_ENT_PAR_MATERIALIZE_IDX1` (`YP_PARAMETER_TYPE_ID`,`YP_PARAMETER_VALUE_STRING`,`YP_ENTITY_TYPE_ID`)
) ENGINE=MyISAM AUTO_INCREMENT=703167 DEFAULT CHARSET=latin1$$
(ersetze YP_INSTANCE mit Kunde, YP_ENTITY mit warenkorb und YP_PARAMETER mit ware)

CREATE TABLE `waren_assoc_all` (
  `kunde_ID` int(11) NOT NULL,
  `warenkorb_TYPE_ID` int(11) NOT NULL,
  `ware_TYPE_ID` int(11) NOT NULL,
  `ware_STRING` varchar(64) NOT NULL,
  `PRIM_KEY` int(11) NOT NULL auto_increment,
  PRIMARY KEY  (`PRIM_KEY`),
  KEY `waren_assoc_all_IDX0` (`kunde_ID`,`warenkorb_TYPE_ID`,`ware_STRING`),
  KEY `waren_assoc_all_IDX1` (`ware_TYPE_ID`,`ware_STRING`,`warenkorb_TYPE_ID`)
) ENGINE=MyISAM AUTO_INCREMENT=703167 DEFAULT CHARSET=latin1$$

der select
SELECT * FROM yp.yp_instance i1
JOIN (
    SELECT q1.YP_INSTANCE_ID 
    FROM
    (
        SELECT YP_INSTANCE_ID FROM yp.yp_ent_par_materialize
        WHERE YP_ENTITY_TYPE_ID = 1             #Equipment
        AND YP_PARAMETER_TYPE_ID=104  #TYPE__EQUIPMENT
        AND (YP_PARAMETER_VALUE_STRING='SFC-C' OR YP_PARAMETER_VALUE_STRING='SFP-G')
    ) q1
    INNER JOIN(
        SELECT YP_INSTANCE_ID FROM yp.yp_ent_par_materialize
        WHERE YP_ENTITY_TYPE_ID = 1             #Equipment
        AND YP_PARAMETER_TYPE_ID=109 #CHANNEL__PROVISION
        AND (YP_PARAMETER_VALUE_STRING='G1310')
    ) q2
    ON q1.YP_INSTANCE_ID=q2.YP_INSTANCE_ID
    
    INNER JOIN(
        SELECT YP_INSTANCE_ID FROM yp.yp_ent_par_materialize
        WHERE YP_ENTITY_TYPE_ID = 1             #Equipment
        AND YP_PARAMETER_TYPE_ID=113 #RATE_PROVISION
        AND (YP_PARAMETER_VALUE_STRING='HS' OR YP_PARAMETER_VALUE_STRING='2G5' OR YP_PARAMETER_VALUE_STRING='CL')
    ) q3
    ON q2.YP_INSTANCE_ID=q3.YP_INSTANCE_ID
    
    INNER JOIN(
        SELECT YP_INSTANCE_ID FROM yp.yp_ent_par_materialize
        WHERE YP_ENTITY_TYPE_ID = 1             #Equipment
        AND YP_PARAMETER_TYPE_ID=431 #FIBER
        AND (YP_PARAMETER_VALUE_STRING='SM')
    ) q4
    ON q3.YP_INSTANCE_ID=q4.YP_INSTANCE_ID
    ) i2
    ON i1.YP_INSTANCE_ID=i2.YP_INSTANCE_ID
WHERE YP_INSTANCE_TYPE_ID = 3               #VARIANT
AND YP_CATEGORY_TYPE_ID = 3000              #PLUG
AND YP_INSTANCE_HIDDEN = 0;
brachte die 4 gewünschten zeilen in 0,015 sekunden. EDIT: nach neustart von server und workbench waren es trotzdem noch schicke 30ms.
kannst du mir das mit der reihenfolge erklären? nach was richtet sich das? /EDIT
wusste gar nicht, dass die reihenfolge im index was zu sagen hat...

weißt du, ob man den cache irgendwie invalidieren kann? MySQL Workbench neustarten oder muss ich an den server ran?

Also wenn du in berlin wohnst, bekommste n bier oder nen tee oder so ;-)



Edited 1 time(s). Last edit at 09/20/2010 07:13AM by Gerald Koch.

Options: ReplyQuote


Subject
Views
Written By
Posted
1875
September 14, 2010 09:24AM
1052
September 17, 2010 02:13AM
989
September 17, 2010 06:27AM
911
September 17, 2010 11:11AM
1015
September 17, 2010 11:56AM
954
September 20, 2010 03:08AM
955
September 20, 2010 03:48AM
885
September 20, 2010 04:11AM
919
September 20, 2010 04:49AM
942
September 20, 2010 05:22AM
1011
September 20, 2010 05:30AM
983
September 20, 2010 05:54AM
979
September 20, 2010 06:45AM
Re: Abfrage in einer Hierarchie
1326
September 20, 2010 07:07AM
1051
September 20, 2010 07:15AM
984
September 20, 2010 07:24AM
1016
September 20, 2010 10:26AM
951
September 20, 2010 10:49AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.