Us 8346761

Embed Size (px)

Citation preview

  • 8/13/2019 Us 8346761

    1/11

    1 2 ) United S t a t e s PatentMuras e t a l .

    US008346761B2

    US 8 , 3 4 6 , 7 6 1 B2J a n . 1 , 2 0 1 3

    1 0 ) Patent N 0 . :4 5 ) Date o f P a t e n t :

    5 4 )

    7 5 )

    7 3 )

    2 1 )2 2 )6 5 )5 1 )5 2 )5 8 )

    METHODAND SYSTEMFORDATAMININGFORAUTOMATICQUERYOPTIMIZATIONI n v e n t o r s : B r i a n Rob ert Muras, R o c h e s t e r , MN

    U S ) ; John Matthew S a n t o s u o s s o ,R o c h e s t e r , MN U )A s s i g n e e : I n t e r n a t i o n a l B u s i n e s s Machines

    C o r p o r a t i o n , A r m o n k , NY U S )N o t i c e : S u b j e c t t o a n y d i s c l a i m e r , t h e t e r m o f h i s

    p a t e n t i s e x t e n d e d o r a d j u s t e d u n d e r 3 5U . S . C . 1 5 4 b ) b y 2 2 9 1 d a y s .

    A p p l . N 0 . : 1 0 / 9 1 1 , 8 4 9F i l e d : A u g . 5 , 2 0 0 4

    Prior P u b l i c a t i o n DataUS 006/0031189 A1 F e b . 9 , 2006I n t . C l .G06F 5 / 1 6 2 0 0 6 . 0 1 )G06F 7 / 2 0 2 0 0 6 . 0 1 )US l. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 0 7 / 7 2 1 ; 707/718Field of Classi?cation Search . . . . . . . . . . . . . . . . . . . . . . . . NoneS e e a p p l i c a t i o n ? l e f o r c o m p l e t e s e a r c h h i s t o r y .

    5 6 ) R e f e r e n c e s C i t e dU . S . PATENTDOCUMENTS

    6 , 360 , 214 B1 3 / 2 0 0 2 E l l i s e t a 1 . . . . . . . . . . . . . . . . . . . . . . . . .. 707 /22002 /01 98867 A1 12/2002 Lohman t a 1 .005 /0065 928 A1 3/2005 Mortensen e t a l .005/0177557 A1 8/2005 Ziauddin e t a 1 . . . . . . . . . . . . . . . . . 707/3

    * c i t e d b y examinerPrimary Examiner ean M orrielusAssistant Examiner lex Gofman7 4 ) A t t o r n e y , A g e n t , o r F i r m *Wood, H e r r o n v a n s ,LLP

    5 7 ) ABSTRACTA a t a b a s e m o n i t o r t r a c k s p e r f o r m a n c e s t a t i s t i c s a n d i n f o rm a t i o n a b o u t t h e e x e c u t i o n o f d i f f e r e n t SQL s t a t e m e n t s . Aq u e r y o p t i m i z e r b e n e ? t s f r o m t h e s e s t a t i s t i c s When g e n e r a ti n g a n a c c e s s p l a n . I n p a r t i c u l a r , t h e q u e r y o p t i m i z e r , uponr e c e i v i n g a n SQL s t a t e m e n t , s e a r c h e s t h e r e c o r d s o f t h e d a t ab a s e m o n i t o r f o r s i m i l a r SQL t a t e m e n t s t h t h a v e p r e v i o u s l yb e e n e x e c u t e d . As a r t o f e t e r m i n i n g t h e b e s t a c c e s s p l a n f o rt h e c u r r e n t SQL s t a t e m e n t , t h e q u e r y o p t i m i z e r c o n s i d e r s t h ei n f o r m a t i o n r e t r i e v e d from t h e d a t a b a s e m o n i t o r . I n h i s W a y ,t h e a c c e s s p l a n t h a t i s g e n e r a t e d c a n a u t o m a t i c a l l y b e t u n e db a s e d on e m p i r i c a l p e r f o r m a n c e e v i d e n c e .

    4 C l a i m s , 5 Drawing S h e e t s3 2 .

    4 s 5 0 ZP A R S E D EXECUTIONSTATEMENT PLAN

    4 6 4 0 4 4DATABASE SQL DATABASE RESULT/ Q U E R Y ZV P A R S E R O P T I M I Z E R E N G I N E 7 S E T

    42

    A T A B A S EDATA 34 MONITORBASE

  • 8/13/2019 Us 8346761

    2/11

  • 8/13/2019 Us 8346761

    3/11

    US. a tent J a n . 1 , 2 0 1 3 S h e e t 2 o f 5 US , 3 4 6 , 7 6 1 B23 02

    DATABASE NGINE EXECUTES SQL STATEMENTS ANDTRACKSPERFORMANCE TATISTICS

    3 0 4NEW QL STATEMENTRECEIVED

    3 0 6QUERY OPTHVIIZER STARTS TO GENERATEACCESS PLAN

    3 08SEARCHPERFORMANCE TATISTICS FORSIMILAR SQL STATMENTS

    3 0USE STATISTICS FROM IMILAR STATEMENT S )

    WHEN GENERATINGTHEACCESSPLAN

    FIG. 3

  • 8/13/2019 Us 8346761

    4/11

    US. a tent J a n . 1 , 2 0 1 3 S h e e t 3 o f 5 US , 3 4 6 , 7 6 1 B2

    4 0 2OPTIMIZER

    RECEIVES sQLQUERY

    NO I S ACCESS PLAN YESALREADYA V A I L A B L E ?

    SEARCH DATABASE 404FOR SIMILAR SQL RQUERY 408 EXECUTION

    I 4 0 6RETRIEvEPERFORMANCE

    STATISTICS ANDINFORMATION 4 0

    IVERIFY

    EXECUTIONPERFORMANCEWAS CCEPTABLE 412lGENERATECURRENTACcEss PLAN USINGPERFORMANCEINFORMATION 4 4

    iEXECUTE CCESS

    PLAN416

    FIG. 4

  • 8/13/2019 Us 8346761

    5/11

    US. a t e n t J a n . 1 , 2 0 1 3 S h e e t 4 o f 5

    QUERY OPTIMIZER RECEIVES SQLSTATEMENT

    IDENTIFY PREVIOUSLY DEVELOPED CCESS PLAN S) FORTHIS STATEMENT

    I

    US 8 , 3 4 6 , 7 6 1 B2

    502

    504

    S 0 6IDENTIFY RECORD S) WITHIN THEDATABASETHATR ELATE TO THESE ACCESS PLAN S)

    i 5 0 8DETERMINE FROM HE RECORD S) WHETHER EXECUTION

    PERFORMANCEWASACCEPTABLEN YES

    5 l 0FORCER E - O P T I M I Z A T I O N T O U S E g I E E I I Q C I C C H E S S T - I P E L A N

    GENERATENEW CCESS QUERYPLAN

    5 4ADJUST ESTIMATEDRUNTIMEFOR

    ORIGINAL ACCESS PLAN

    FIG. 5

    512

  • 8/13/2019 Us 8346761

    6/11

    US. a t e n t J a n . 1 , 2 0 1 3 S h e e t 5 o f 5

    IDENTIFY FROMDATABASE HOST ARIABLESUSED IN QUERIES WITHPOORPERFORMANCE

    lQUERY OPTIMIZERRECEIVES AN QL STATEMENT

    ISTARTTO GENERATEACCESS PLAN

    IARE CURRENTHOSTVARIABLES N THE IST OF

    IDENTIFIED HOST ARIABLES?

    FORCERE-OPTIMIZATIONTOENSUREANEWACCESSPLAN S

    GENERATED

    602

    604

    606

    608

    CONTINUEGENERATING CCESSPLAN N THENORMAL MANNER

    US 8 , 3 4 6 , 7 6 1 B2

    NO

    610

    FIG. 6

    612

  • 8/13/2019 Us 8346761

    7/11

    US 8 , 3 4 6 , 7 6 1 B21

    METHODAND SYSTEMFORDATAMININGFORAUTOMATICQUERYOPTIMIZATION

    FIELD OFTHE INVENTIONThe i n v e n t i o n r e l a t e s t o d a t a b a s e management s y s t e m s ,

    a n d i n p a r t i c u l a r , t o q u e r y o p t i m i z e r s .BACKGROUNDOFTHE INVENTION

    Databases a r e used o s t o r e information o r an innumerablen u m b e r o f a p p l i c a t i o n s , i n c l u d i n g v a r i o u s c o m m e r c i a l ,i n d u s t r i a l , t e c h n i c a l , s c i e n t i ? c a n d e d u c a t i o n a l a p p l i c a t i o n s .As t h e r e l i a n c e o n i n f o r m a t i o n i n c r e a s e s , b o t h t h e volume o fi n f o r m a t i o n s t o r e d i n most a t a b a s e s , a s W e l l a s t h e number ofu s e r s Wishing t o a c c e s s t h a t i n f o r m a t i o n , l i k e W i s e i n c r e a s e s .M o r e o v e r , a s t h e volume of n f o r m a t i o n i n a d a t a b a s e , and h enumber f s e r s W i s h i n g t o a c c e s s t h e d a t a b a s e , i n c r e a s e s , t h eamount o f computing r e s o u r c e s r e q u i r e d t o m an ag e such adatabase i n c r e a s e s a s W e l l .

    D a t a b a s e management s y s t e m s DBMSs), Which a r e t h ecom puter programs t h a t a r e used t o a c c e s s t h e informations t o r e d i n d a t a b a s e s , t h e r e f o r e o f t e n r e q u i r e t r e m e n d o u sr e s o u r c e s t o h a n d l e t h e heavy Workloads p l a c e d on s u c hs y s t e m s . As s u c h , s i g n i ? c a n t r e s o u r c e s h a v e been d e v o t e d t oi n c r e a s i n g t h e p e r f o r m a n c e o f a t a b a s e m a n a g e m e n t s y s t e m sW i t h r e s p e c t t o p r o c e s s i n g s e a r c h e s , o r q u e r i e s , t o d a t a b a s e s .

    I m p r o v e m e n t s t o b o t h c o m p u t e r h a r d W a r e and s o f t W a r eh a v e i m p r o v e d t h e c a p a c i t i e s o f c o n v e n t i o n a l d a t a b a s e mana g e m e n t s y s t e m s . F o r e x a m p l e , i n t h e h a r d W a r e r e a l m ,i n c r e a s e s i n m i c r o p r o c e s s or p e r f o r m a n c e , c o u p l e d W i t hi m p r o v e d memory m a n a g e m e n t s y s t e m s , h a v e i m p r o v e d t h enumber o f q u e r i e s t h a t a p a r t i c u l a r m i c r o p r o c e s s o r c a n p e rform i n a g i v e n u n i t o f t i m e . F u r t h e r m o r e , t h e u s e o f m u l t i p l em i c r o p r o c e s s o r s a n d / o r m u l t i p l e n e t W o r k e d c o m p u t e r s h a sf u r t h e r i n c r e a s e d t h e c a p a c i t i e s o f many d a t a b a s e management s y s t e m s .

    From s o f t W a r e s t a n d p o i n t , t h e u s e of e l a t i o n a l d a t a b a s e s ,Which r g a n i Z e i n f o r m a t i o n i n t o f o r m a l l y - d e ? n e d t a b l e s c o ns i s t i n g o f o W s and o l u m n s , and Which r e t y p i c a l l y a c c e s s e du s i n g a s t a n d a r d i Z e d l a n g u a g e s u c h a s S t r u c t u r e d Query Lang u a g e S Q L ) , h a s s u b s t a n t i a l l y i m p r o v e d p r o c e s s i n g e ? ic i e n c y , a s W e l l s s u b s t a n t i a l l y s i m p l i ? e d t h e c r e a t i o n , o r g an i Z a t i o n , and e x t e n s i o n o f i n f o r m a t i o n W i t h i n a d a t a b a s e .F u r t h e r m o r e , s i g n i ? c a n t d e v e l o p m e n t e f f o r t s h a v e b e e nd i r e c t e d t o W ar d q u e r y o p t i m i z a t i o n , W h e r e b y t h e e x e c u t i o no f p a r t i c u l a r s e a r c h e s , o r q u e r i e s , i s o p t i m i Z e d i n a n a u t omated manner o minimiZe t h e amount of e s o u r c e s r e q u i r e dt o execute each q u e r y .

    T h r o u g h t h e i n c o r p o r a t i o n o f v a r i o u s h a r d W a r e a n d s o f tWare i m p r o v e m e n t s , many h i g h p e r f o r m a n c e d a t a b a s e m a nagement systems a r e a b l e t o handle hundreds o r even thous a n d s o f q u e r i e s e a c h s e c o n d , e v e n on d a t a b a s es c o n t a i n i n gm i l l i o n s o r b i l l i o n s o f e c o r d s . HoWever, f u r t h e r i n c r e a s e s i ni n f o r m a t i o n volume and Workload a r e i n e v i t a b l e , s o c o n t i nued advancements i n d a t a b a s e management s y s t e m s a r e s t i l lr e q u i r e d .

    One a r e a t h a t has been a f e r t i l e a r e a f o r academic andc o r p o r a t e r e s e a r c h i s t h a t o f i m p r o v i n g t h e d e s i g n s o f t h eq u e r y o p t i m i Z e r s u t i l i Z e d i n many c o n v e n t i o n a l d a t a b a s emanagement s y s t e m s . The r i m a r y t a s k o f a q u e r y o p t i m i Z e ri s t o choose t h e most e f ? c i e n t Way to e x e c u t e each d a t a b a s eq u e r y , o r r e q u e s t , p a s s e d o t h e d a t a b a s e management s y s t e mby a u s e r . The o u t p u t o f a n o p t i m i Z a t i o n p r o c e s s i s t y p i c a l l yr e f e r r e d t o a s an e x e c u t i o n p l a n , a c c e s s p l a n , o r j u s t p l a n a n d i s f r e q u e n t l y d e p i c t e d a s a t r e e g r a p h . Such a p l a nt y p i c a l l y i n c o r p o r a t e s o f t e n i n a p r o p r i e t a r y f o r m u n i q u e t o

    20

    25

    30

    35

    40

    45

    50

    55

    60

    6 5

    2e a c h o p t i m i z e r / D B M S ) l o W - l e v e l i n f o r m a t i o n t e l l i n g t h ed a t a b a s e e n g i n e t h a t u l t i m a t e l y h a n d l e s a q u e r y p r e c i s e l yWhat s t e p s t o t a k e a n d i n What o r d e r ) t o e x e c u t e t h e q u e r y .A l s o t y p i c a l l y a s s o c i a t e d W i t h e a c h g e n e r a t ed p l a n i s a n o p t im i Z e r e s t i m a t e of o W o n g t W i l l t a k e t o r u n t h e q u e r y u s i n gt h a t p l a n .An p t i m i Z e r s j o b i s o f t e n n e c e s s a r y a n d d i f ? c u l t b e c a u s eo f h e e n o r m o u s number i . e . , c o u n t a b l y i n ? n i t e n u m b e r ) o fp o s s i b l e q u e r y f o r m s t h a t can b e g e n e r a t e d i n a d a t a b a s emanagement s y s t e m , e . g . , due to f a c t o r s such a s t h e u s e ofSQL u e r i e s W i t h a n y number f e l a t i o n a l t a b l e s made p o fc o u n t l e s s d a t a c o l u m n s o f v a r i o u s t y p e s , t h e t h e o r e t i c a l l yi n ? n i t e number o f m e t h o d s o f a c c e s s i n g t h e a c t u a l d a t ar e c o r d s from e a c h t a b l e r e f e r e n c e d e . g . , u s i n g a n i n d e x , ah a s h t a b l e , e t c . ) , t h e p o s s i b l e c o m b i n a t i o n s o f t h o s e m e t h o d so f a c c e s s am on g l l t h e t a b l e s r e f e r e n c e d , e t c . An p t i m i Z e r so f t e n p e r m i t t e d t o r e W r i t e a q u e r y o r p o r t i o n o f t ) i n t o a n ye q u i v a l e n t f o r m , a n d s i n c e f o r a n y g i v e n q u e r y t h e r e a r et y p i c a l l y many e q u i v a l e n t f o r m s , a n o p t i m i Z e r h a s a c o u n ta b l y i n ? n i t e u n i v e r s e o f e x t r e m e l y d i v e r s e p o s s i b l e s o l u t i o n sp l a n s ) t o c o n s i d e r . On t h e o t h e r h a n d , a n o p t i m i Z e r i s o f t e n

    r e q u i r e d t o u s e minimal s y s t e m r e s o u r c e s g i v e n t h e d e s i r a b i li t y f o r h i g h t h r o u g h p u t . As u c h , a n o p t i m i Z e r o f t e n h a s o n l ya l i m i t e d amount of i m e t o p a r e t h e s e a r c h s p a c e of o s s i b l ee x e c u t i o n p l a n s doWn t o a n o p t i m a l p l a n f o r a p a r t i c u l a rq u e r y .

    Another automated t o o l t h a t i s a p a r t o f m a n y d a t a b a s emanagement s y s t e m s i s a d a t a b a s e m o n i t o r . I t i s used t og a t h e r p e r f o r m a n c e s t a t i s t i c s r e l a t e d t o SQL q u e r i e s r u nW i t h i n t h e d a t a b a s e management s y s t e m . The d a t a c o l l e c t e dby t h e d a t a b a s e m o n i t o r i s t y p i c a l l y c o l l e c t e d i n a d a t a b a s e? l e i t s e l f Where i t c a n be q u e r i e d by a t r a i n e d u s e r t o h e l pi d e n t i f y a n d t u n e p e r f o r m a n c e p r o b l e m a r e a s . A a t a b a s emonitor t y p i c a l l y t r a c k s t h e na me of q u e r y , t h e na me of h et a b l e s a c c e s s e d b y t h e q u e r y , t h e i n d i c e s u s e d b y t h e q u e r y i fa n y ) , t h e j o i n p a r a m e t e r s o f t h e q u e r y , a n d o t h e r p e r t i n e n ti n f o r m a t i o n such a s t h e d u r a t i o n of time t h e query took t oc o m p l e t e . The e r f o r m a n c e s t a t i s t i c s c o l l e c t e d b y a d a t a b a s em o n i t o r a r e t y p i c a l l y l a r g e i n volume a n d r e q u i r e a knoWle d g e a b l e SQL a d m i n i s t r a t o r t o i n t e r p r e t a n d u s e .

    T y p i c a l q u e r y o p t i m i Z e r s s t o r e i n f o r m a t i o n a b o u t p r e v io u s l y e n c o u n t e r e d q u e r i e s a n d t h e a c c e s s p l a n s t h a t Werec r e a t e d f o r s u c h q u e r i e s . When p r e v i o u s q u e r y i s o n c e a g a i ne n c o u n t e r e d , t h e s e o p t i m i Z e r s u s e p r e v i o u s a c c e s s p l a n s t oa v o i d t h e t i m e and c o s t o f r e - c r e a t i n g an a c c e s s p l a n r e g a r dl e s s o f hoW t h e e a r l i e r a c c e s s p l a n p e r f o r m e d . T h u s , t h e c u rr e n t d e t e r m i n a t i o n and a n a l y s i s by t h e o p t i m i Z e r t o r e - u s e ap l a n s i m p l y c o n s i d e r s W h e t h e r a s i m i l a r a c c e s s p l a n i s a v a i la b l e f o r u s e and d o e s n o t c o n s i d e r t h e p a s t p e r f o r m a n c es t a t i s t i c s of t h a t p l a n such a s t h o s e t h a t a r e c o l l e c t e d by ad a t a b a s e m o n i t o r . T h u s , t h e r e r e m a i n s t h e n e e d i n p r i o r d a t ab a s e e n v i r o n m e n t s f o r a s y s t e m t h a t p e r m i t s s e l e c t i n g o rmodifying a q u e r y a c c e s s p l a n based o n e m p i r i c a l e v i d e n c ea b o u t t h e p e r f o r m a n c e s t a t i s t i c s o f p r e v i o u s l y e x e c u t e da c c e s s p l a n s t h a t Were c o l l e c t e d b y a d a t a b a s e m o n i t o r .

    SUMMARYOFTHE INVENTIONEmbodiments of h e p r e s e n t i n v e n t i o n r e l a t e t o a d a t a b a s e

    m o n i t o r t h a t t r a c k s p e r f o r m a n c e s t a t i s t i c s a n d i n f o r m a t i o na b o u t t h e e x e c u t i o n o f d i f f e r e n t d a t a b a s e q u e r i e s and a q u e r yo p t i m i Z e r t h a t b e n e ? t s f r o m t h e s e s t a t i s t i c s When g e n e r a t i n ga n a c c e s s p l a n . I n a r t i c u l a r , t h e q u e r y o p t i m i Z e r , upon e c e i vi n g a d a t a b a s e q u e r y , s e a r c h e s a d a t a b a s e o f performances t a t i s t i c s f o r s i m i l a r d a t a b a s e q u e r i e s t h a t h a v e p r e v i o u s l yb e e n e x e c u t e d . As a r t o f e t e r m i n i n g t h e b e s t a c c e s s p l a n f o rt h e c u r r e n t d a t a b a s e q u e r y , t h e q u e r y o p t i m i Z e r c o n s i d e r s t h e

  • 8/13/2019 Us 8346761

    8/11

    US 8 , 3 4 6 , 7 6 1 B23

    i n f o r m a t i o n r e t r i e v e d from h e s t a t i s t i c s d a t a b a se . I n h i s w a y ,t h e a c c e s s p l a n t h a t i s g e n e r a t e d c a n a u t o m a t i c a l l y b e t u n e db a s e d o n e m p i r i c a l e v i d e n c e o f p a s t p e r f o r m a n c e .One a s p e c t o f t h e p r e s e n t i n v e n t i o n r e l a t e s t o a method f o rg e n e r a t i n g an a c c e s s p l a n . I n a c c o r d a n c e w it h t h i s method, ap a r t i c u l a r s e t o f p a s t p e r f o r m a n c e s t a t i s t i c s i s i d e n t i ? e d t h a tr e l a t e s t o a d a t a b a s e q u e r y . When h e q u e r y o p t i m i Z e r g e n e ra t e s an a c c e s s plan f o r t h e c u r r e n t d a t a b a s e q u e r y , i t s generat i o n i s b a s e d a t l e a s t i n p a r t on t h e p a r t i c u l a r s e t o f p a s tp e r f o r m a n c e s t a t i s t i c s .

    A n o t h e r a s p e c t o f t h e p r e s e n t i n v e n t i o n r e l a t e s t o a n o t h e rmethod o r g e n e r a t i n g an c c e s s p l a n i n which r e s p e c t i v e s e to f p a s t p e r f o r m a n c e s t a t i s t i c s i s m a i n t a i n e d f o r e a c h o f ap l u r a l i t y o f r e v i o u s l y e x e c u t e d d a t a b a s e u e r i e s . From h e s es t a t i s t i c s , a p a r t i c u l a r s e t o f p a s t p e r f o r m a n c e s t a t i s t i c s i si d e n t i ? e d c o r r e s p o n d i n g t o a p r e v i o u s l y e x e c u t e d d a t a b a s equery s i m i l a r t o a c u r r e n t d a t a b a s e query and h e performanceo f a n a c c e s s p l a n i d e n t i ? e d w i t h i n t h e p a r t i c u l a r s e t o f p a s tp e r f o r m a n c e s t a t i s t i c s i s a n a l y Z e d . T h e q u e r y o p t i m i Z e r g e ne r a t e s a c u r r e n t a c c e s s plan f o r t h e c u r r e n t database querybased t l e a s t i n p a r t o n t h e a c c e s s p l a n t h a t was a n a l y Z e d .

    Y e t a n o t h e r a s p e c t o f t h e p r e s e n t i n v e n t i o n r e l a t e s t oa n o t h e r method f o r g e n e r a t i n g an a c c e s s p l a n t h a t a l s oi n c l u d e s a r e s p e c t iv e s e t o f p a s t p e r f o r m a n c e s t a t i s t i c s b e i n gm a i n t a i n e d f o r e a c h o f a p l u r a l i t y o f p r e v i o u s l y e x e c u t e dd a t a b a s e q u e r i e s . A u r r e n t a c c e s s p l a n f o r a c u r r e n t d a t a b a s eq u e r y s i d e n t i ? e d a n d t h e n , from h e s t a t i s t i c s , a p a r t i c u l a r s e to f a s t p e r f o r m a n c e s t a t i s t i c s i s i d e n t i ? e d c o r r e s p o n d i n g t o ap r e v i o u s l y e x e c u t e d d a t a b a s e q u e r y t h a t u s e d t h e c u r r e n ta c c e s s p l a n . The p e r f o r m a n c e o f t h e p r e v i o u s l y e x e c u t e dd a t a b a s e q u e r y i s a n a l y Z e d and s e d t o d e t e r m i n e whether t or e - u s e t h e c u r r e n t access p l a n .

    S t i l l a n o t h e r a s p e c t of t h e p r e s e n t i n v e n t i o n r e l a t e s to amethod o r g e n e r a t i n g an a c c e s s p l a n t h a t i n c l u d e s m a i n t a i ni n g i n n o n - v o l a t i l e memory a r e s p e c t iv e s e t o f p a s t p e r f o rmance t a t i s t i c s f o r e a c h o f a p l u r a l i t y o f r e v i o u s l y e x e c u t e dd a t a b a s e q u e r i e s . A e t o f h o s t v a r i a b l e s r e f e r e n c e s i s i d e n t i?ed i t h i n t h o s e r e s p e c t i v e s e t s o f a s t p e r f o r m a n c e s t a t i s t i c st h t r e l a t e t o d a t a skew p e r f o r m a n c e d e g r a d a t i o n . The q u e r yo p t i m i Z e r f o r c e s r e - o p t i m i Z a t i o n t o g e n e r a t e a new a c c e s sp l a n f o r t h e c u r r e n t d a t a b a s e q u e r y i f t h e c u r r e n t d a t a b a s equery i n c l u d e s one or more host v a r i a b l e s within t h e i d e n t i?ed s e t of o s t v a r i a b l e s .

    BRIEF DESCRIPTION OFTHE DRAWINGSF I G . 1 i s a b l o c k diagram o f a networked comp uter s y s t e m

    i n c o r p o r a t i n g a d a t a b a s e management s y s t e m c o n s i s t e n t w i t ht h e i n v e n t i o n .

    F I G . 2 i s a b l o c k d i a g r a m i l l u s t r a t i n g t h e p r i n c i p a l co mpon e n t s and ?ow o f i n f o r m a t i o n t h e r e b e t w e e n i n t h e d a t a b a s emanagement s y s t e m o f F I G . 1 .

    FIG. 3 i l l u s t r a t e s a ?owchart of an exemp lary me t h od o r aq u e r y o p t i m i Z e r t o u s e p a s t p e r f o r m a n c e s t a t i s t i c s when e ne r a t i n g an a c c e s s p l a n .

    F I G . 4 i l l u s t r a t e s a ?owchart o f an exemplary method ofl o c a t i n g a s i m il a r SQL t a t e m e n t i n a d a t a b a s e m o n i t o r sr e c o r d s t o use w h e n g e n e r a t i n g an a c c e s s p l a n .

    F I G . 5 i l l u s t r a t e s a ?owchart of an exemplary method f o rd e t e r m i n i n g h o w t o g e n e r a t e an a c c e s s p l a n based on h o ww e l l a s i m i l a r a c c e s s p l a n p e r f o r m e d in t h e p a s t .

    F I G . 6 i l l u s t r a t e s a ?owchart of an exemplary method f o rd e t e r m i n i n g h o w t o g e n e r a t e an a c c e s s p l a n based on p a s ts t a t i s t i c s r e g a r d i n g d a t a s k ew .

    DETAILEDDESCRIPTIONAs m e n t i o n e d a b o v e , t h e embodiments d i s c u s s e d h e r e i na f t e r u t i l i Z e a d a t a b a s e e n g i n e a n d o p t i m i Z e r framework t h a t

    20

    25

    30

    35

    40

    45

    50

    55

    60

    6 5

    4s u p p o r t s e l e c t i n g an a c c e s s p l a n b a s e d on p r e v i o u s l y c o ll e c t e d p e r f o r m a n c e s t a t i s t i c s o f s i m i l a r a c c e s s p l a n s t h a t h a v ep r e v i o u s l y e x e c u t e d . I n s t ea d o f m e r e l y r e l y i n g o n e s t i m a t e dc o s t s f o r t h e d i f f e r e n t a c c e s s p l a n s t r a t e g i e s , t h e q u e r y o p t imiZer s e s t h e e m p i r i c a l e v i d e n c e from r e v i o u s q u e r y e x e c ut i o n s w hen d e t e r m i n i n g h o w to g e n e r a t e t h e a c c e s s p l a n . As p e c i ? c i m p l e m e n t a t i o n o f s u c h a d a t a b a s e e n g i n e a n d o p t im i Z e r f r a m e w o r k c a p a b l e o f s u p p o r t i n g h i s f u n c t i o n a l i t y i n amanner c o n s i s t e n t with t h e i n v e n t i o n w i l l be d i s c u s s e d i ng r e a t e r d e t a i l b e l o w . However, p r i o r t o a d i s c u s s i o n o f s u c h as p e c i ? c i m p l e m e n t a t i o n , a b r i e f d i s c u s s i o n w i l l b e p r o v i d e dr e g a r d i n g a n e x e m p l a r y h a r d w a r e a n d s o f t w a r e e n v i r o n m e n tw i t h i n which s u c h a n o p t i m i Z e r framework m a y e s i d e .

    T u r n i n g now t o t h e D r a w i n g s , w h e r e i n l i k e numbersd e n o t e l i k e p a r t s t h r o u g h o u t t h e s e v e r a l v i e w s , F I G . 1 i l l u st r a t e s an exempla ry hardware and s o f t w a r e e n v i r o n m e n t f o ran a p p a r a t u s 10 s u i t a b l e f o r implementing a d a t a b a s e mana g e m e n t s y s t e m t h a t c o n s i d e r s p r e v i o u s p e r f o r m a n c e s t a t i st i c s when e l e c t i n g a c c e s s p l a n s c o n s i s t e n t w i t h t h e i n v e n t i o n .F o r t h e p u r p o s e s o f h e i n v e n t i o n , a p p a r a t u s 1 0 m a y e p r e s e n tp r a c t i c a l l y a n y t y p e o f c o m p u t e r , c o m p u t e r s y s t e m o r o t h e rp r o g r a m m a b l e l e c t r o n i c d e v i c e , i n c l u d i n g a c l i e n t c o m p u t e r ,a s e r v e r computer, a p o r t a b l e computer, a handheld computer,an embedded o n t r o l l e r , e t c . M o r e o v e r , a p p a r a t u s 1 0 m a y beimplemented u s i n g one o r more networked computers, e . g . ,i n a c l u s t e r o r o t h e r d i s t r i b u t e d computing s y s t e m . A p p a r a t u s10 w i l l h e r e i n a f t e r a l s o be r e f e r r e d t o a s a computer,a l t h o u g h i t s h o u l d b e a p p r e c i a t e d t h e t e r m a p p a r a t u s maya l s o i n c l u d e o t h e r s u i t a b l e programmable e l e c t r o n i c d e v i c e sc o n s i s t e n t w i t h t h e i n v e n t i o n .

    Computer 1 0 t y p i c a l l y i n c l u d e s a t l e a s t one p r o c e s s o r 1 2coupled t o a m e m o r y 1 4 . P r o c e s s o r 12 may e p r e s e n t one o rmore r o c e s s o r s e . g . , m i c r o p r o c e s s o r s ) , and memory 4 m a yr e p r e s e n t t h e random a c c e s s m e m o r y RAM) d e v i c e s c o mp r i s i n g t h e main s t o r a g e o f computer 1 0 , a s w e l l a s a n ys u p p l e m e n t a l l e v e l s o f memory, e . g . , c a c h e m e m o r i e s , nonv o l a t i l e o r backup m emories e . g . , programmable o r ? a s hm e m o r i e s ) , r e a d - o n l y m e m o r i e s , e t c . I n a d d i t i o n , memory 1 4m a y b e c o n s i d e r e d t o i n c l u d e memory s t o r a g e p h y s i c a l l yl o c a t e d e l s e w h e r e i n c o m p u t e r 1 0 , e . g . , a n y c a c h e memory i na processor 1 2 , a s well a s any s t o r a g e c a p a c i t y used a s av i r t u a l m e m or y , e . g . , a s stored o n a mass storage device 16 oron a n o t h e r computer c o u p l e d t o computer 1 0 v i a network 1 8

    e . g . , a c l i e n t c o m p u t e r 2 0 ) .Computer 0 a l s o t y p i c a l l y r e c e i v e s a number f i n p u t s a n do u t p u t s f o r c o m m u n i c a t i n g i n f o r m a t i o n e x t e r n a l l y . F o r i n t e rf a c e with a u s e r o r o p e r a t o r , computer 10 t y p i c a l l y i n c l u d e sone o r m ore user i n p u t d e v i c e s 22 e . g . , a keyboard, a mouse,a t r a c k b a l l , a j o y s t i c k , a t o u c h p a d , a n d / r a microphone,am on g t h e r s ) and a d i s p l a y 24 e . g . , a CRT o n i t o r , an LCDd i s p l a y p a n e l , a n d / o r a s p e a k e r , among o t h e r s ) . O t h e r w i s e ,u s e r i n p u t m a y be r e c e i v e d v i a a n o t h e r computer e . g . , ac o m p u t e r 2 0 ) i n t e r f a c e d w i t h c o m p u t e r 1 0 o v e r n e t w o r k 1 8 ,or via a dedicated workstatio n i n t e r f a c e or t h e l i k e .

    F o r a d d i t i o n a l s t o r a g e , computer 1 0 m a y a l s o i n c l u d e oneo r m o re mass s t o r a g e d e v i c e s 1 6 , e . g . , a ?oppy o r o t h e rremovable i s k d r i v e , a h a r d d i s k d r i v e , a d i r e c t a c c e s s s t o r a g ed e v i c e DASD), an o p t i c a l d r i v e e . g . , a CD r i v e , a DVDd r i v e , e t c . ) , a n d / o r a t a p e d r i v e , among t h e r s . F u r t h e r m o r e ,computer 10 may include an i n t e r f a c e with one or m o ren e t w o r k s 1 8 e . g . , a LAN, a WAN, w i r e l e s s n e t w o r k , a n d / o rt h e I n t e r n e t , among o t h e r s ) t o p e r m i t t h e c o m m u n i c a t i o n o fi n f o r m a t i o n w i t h o t h e r c o m p u t e r s c o u p l e d t o t h e n e t w o r k . I ts h o u l d b e a p p r e c i a t e d t h a t c o m p u t e r 1 0 t y p i c a l l y i n c l u d e ss u i t a b l e a n a l o g a n d / r i g i t a l i n t e r f a c e s between r o c e s s o r 1 2a n d e a c h o f components 1 4 , 1 6 , 1 8 , 2 2 a n d 2 4 as i s w e l lk n o wn i n t h e a r t .

  • 8/13/2019 Us 8346761

    9/11

    US 8 , 3 4 6 , 7 6 1 B25

    Computer 1 0 o p e r a t e s u n d e r t h e c o n t r o l o f a n o p e r a t i n gsystem 3 0 , and e x e c u t e s o r o t h e r w i s e r e l i e s upon v a r i o u sc o m p u t e r s o f t w a r e a p p l i c a t i o n s , c o m p o n e n t s , p r o g r a m s ,o b j e c t s , m o d u l e s , d a t a s t r u c t u r e s , e t c . e . g . , d a t a b a s e management s y s t e m 3 2 a n d d a t a b a s e 3 4 , among t h e r s ) . M o r e o v e r ,v a r i o u s a p p l i c a t i o n s , c o m p o n e n t s , p r o g r a m s , o b j e c t s , modu l e s , e t c . may l s o execute o n one or m or e processors i na n o t h e r c o m p u t e r c o u p l e d t o c o m p u t e r 1 0 v i a a n e t w o r k 1 8 ,e . g . , i n a d i s t r i b u t e d o r c l i e n t - s e r v e r computing e n v i r o n m e n t ,w h e r e b y t h e p r o c e s s i n g r e q u i r e d t o i m p l e m e n t t h e f u n c t i o n so f a computer program m a y e a l l o c a t e d t o m u l t i p l e computers over a n e t w o r k .

    T u r n i n g b r i e ? y t o F I G . 2 , a n e x e m p l a r y i m p l e m e n t a t i o n o fd a t a b a s e management s y s t e m 3 2 i s s h o w n . The p r i n c i p a lcomponents o f d a t a b a s e management s y s t e m 32 t h a t a r e r e le v a n t t o query o p t i m i Z a t i o n a r e an SQL a r s e r 4 0 , c o s t - b a s e do p t i m i Z e r 4 2 a n d d a t a b a s e e n g i n e 4 4 . SQL a r s e r 4 0 r e c e i v e sfrom a u s e r a d a t a b a s e query 4 6 , w h i c h i n t h e i l l u s t r a t e de m b o d i m e n t , i s p r o v i d e d i n t h e form o f a n SQL s t a t e m e n t .SQL a r s e r 4 0 t h e n g e n e r a t e s a p a r s e d s t a t e m e n t 4 8 t h e r ef r o m , w h i c h s p a s s e d o o p t i m i Z e r 4 2 f o r q u e r y o p t i m i Z a t i o n .As a r e s u l t of query o p t i m i Z a t i o n , an execution o r a c c e s s plan5 0 s g e n e r a t e d , o f t e n u s i n g d a t a s u c h s p l a t f o r m a p a b i l i t i e s ,q u e r y c o n t e n t i n f o r m a ti o n , e t c . , t h a t i s s t o r e d i n d a t a b a s e 3 4 .Once g e n e r a t e d , t h e e x e c u t i o n p l a n i s f o r w a r d e d t o d a t a b a s ee n g i n e 44 f o r e x e c u t i o n o f t h e d a t a b a s e q u e r y on t h e i n f o rmation i n d a t a b a s e 3 4 . The r e s u l t o f t h e e x e c u t i o n o f t h ed a t a b a s e q u e r y i s t y p i c a l l y s t o r e d i n a r e s u l t s e t , a s r e p r es e n t e d a t block 5 2 .

    While t h e d a t a b a s e e n g i n e 4 4 e x e c u t e s t h e q u e r y 4 6 , ad a t a b a s e m o n i t o r 6 0 t r a c k s p e r f o r m a n c e o f t h e e x e c u t i o n andc o l l e c t s s t a t i s t i c s a n d o t h e r i n f o r m a t i o n a b o u t h o w h e p l a n 5 0i s p e r f o r m i n g . The s t a t i s t i c s a n d i n f o r m a t i o n f o r e a c h q u e r y46 a r e s t o r e d i n a monitor a t a b a s e 6 2 . The a t a b a s e monitor6 2 i s a d v a n t a g e o u s l y a r e l a t i o n a l d a t a b a s e t h a t p e r m i t s e a s ys e a r c h i n g a n d r e t r i e v a l o f a t a .

    O t h e r c o m p o n e n t s may e i n c o r p o r a t e d i n t o s y s t e m 3 2 , a sm a y t h e r s u i t a b l e d a t a b a s e management r c h i t e c t u r e s . O t h e rd a t a b a s e p r o g r a m m i n g a n d o r g a n i z a t i o n a l a r c h i t e c t u r e s maya l s o b e u s e d c o n s i s t e n t w i t h t h e i n v e n t i o n . T h e r e f o r e , t h ei n v e n t i o n i s n o t l i m i t e d t o t h e p a r t i c u l a r i m p l e m e n t a t i o n d i sc u s s e d h e r e i n .

    I n g e n e r a l , t h e r o u t i n e s e x e c u t e d o i m p l e m e n t t h e embodiments o f t h e i n v e n t i o n , whether implemented a s p a r t o f ano p e r a t i n g s y s t e m o r a s p e c i ? c a p p l i c a t i o n , c o m p o n e n t , p r ogram, o b j e c t , module o r sequence of i n s t r u c t i o n s , o r even as u b s e t t h e r e o f , w i l l b e r e f e r r e d t o h e r e i n a s computer p r og r a m c o d e , o r s i m p l y p r o g r a m c o d e . P r o g r a m c o d e t y p ic a l l y comprises one o r more i n s t r u c t i o n s t h a t a r e r e s i d e n t a tv a r i o u s t i m e s i n v a r i o u s m e m or y and s t o r a g e d e v i c e s i n ac o m p u t e r , and h a t , w h e n e a d and e x e c u t e d b y one o r morep r o c e s s o r s i n a c o m p u t e r , c a u s e t h a t computer to perform t h es t e p s n e c e s s a r y t o e x e c u t e s t e p s o r e l e m e n t s embodying t h ev a r i o u s a sp e c t s o f t h e i n v e n t i o n . M o r e o v e r , w h i l e t h e i n v e nt i o n h a s and h e r e i n a f t e r w i l l be d e s c r i b e d i n t h e c o n t e x t o ff u l l y f u n c t i o n i n g c o m p u t e r s a n d c o m p u t e r s y s t e m s , t h o s es k i l l e d i n t h e a r t w i l l a p p r e c i a t e t h a t t h e v a r i o u s embodimentsof h e i n v e n t i o n a r e c a p a b l e of e i n g d i s t r i b u t e d a s a programp r o d u c t i n a v a r i e t y o f f o r m s , a n d t h a t t h e i n v e n t i o n a p p l i e se q u a l l y r e g a r d l e s s o f t h e p a r t i c u l a r t y p e o f s i g n a l b e a r i n gmedia s e d o a c t u a l l y c a r r y o u t t h e d i s t r i b u t i o n . Examples o fs i g n a l b e a r i n g media i n c l u d e b u t a r e n o t l i m i t e d to r e c o r d a b l et y p e media s u c h a s v o l a t i l e and o n - v o l a t i l e m e m or y e v i c e s ,? o p p y a n d o t h e r r e m o v a b l e d i s k s , h a r d d i s k d r i v e s , m a g n e t i ct a p e , o p t i c a l d i s k s e . g . , C D - R O M s , D V D s , e t c . ) , a m o n go t h e r s , and t r a n s m i s s i o n t y p e media s u c h a s d i g i t a l and a n al o g c o m m u n i c a t i o n l i n k s .

    20

    25

    30

    35

    40

    45

    50

    55

    60

    6 5

    6I n a d d i t i o n , v a r i o u s program c o d e d e s c r i b e d h e r e i n a f t e rm a y e i d e n t i ? e d b a s e d upon h e a p p l i c a t i o n w i t h i n which t

    i s i m p l e m e n t e d i n a s p e c i ? c embodiment o f t h e i n v e n t i o n .H o w e v e r , t s h o u l d b e a p p r e c i a t e d h a t a n y a r t i c u l a r p r o g r a mn o m e n c l a t u r e t h a t f o l l o w s i s u s e d m e r e l y f o r c o n v e n i e n c e ,and t h u s t h e i n v e n t i o n s h o u l d n o t be l i m i t e d to u s e s o l e l y i na n y s p e c i ? c a p p l i c a t i o n i d e n t i ? e d a n d / o r i m p l i e d b y s u c hn o m e n c l a t u r e . F u r t h e r m o r e , g i v e n t h e t y p i c a l l y e n d l e s s numb e r of manners i n which com puter programs m a y be o r g an i Z e d i n t o r o u t i n e s , p r o c e d u r e s , m e t h o d s , m o d u l e s , o b j e c t s ,and h e l i k e , a s w e l l a s t h e v a r i o u s manners i n which programf u n c t i o n a l i t y may e a l l o c a t e d among a r i o u s s o f t w a r e l a y e r st h a t a r e r e s i d e n t w i t h i n a t y p i c a l c o m p u t e r e . g . , o p e r a t i n gs y s t e m s , l i b r a r i e s , A P I s , a p p l i c a t i o n s , a p p l e t s , e t c . ) , i t s h o u l db e a p p r e c i a t e d t h a t t h e i n v e n t i o n i s n o t l i m i t e d t o t h e s p e c i ? co r g a n i z a t i o n a n d a l l o c a t i o n o f p r o g r a m f u n c t i o n a l i t yd e s c r i b e d h e r e i n .

    T h o s e s k i l l e d in t h e a r t w i l l r e c o g n i Z e t h a t t h e e x e m p l a r yenvironment i l l u s t r a t e d i n FIGS. 1 and 2 i s n o t i n t e n d e d t ol i m i t t h e p r e s e n t i n v e n t i o n . I n d e e d , t h o s e s k i l l e d i n t h e a r t w i l lr e c o g n i Z e t h a t o t h e r a l t e r n a t i v e hardware a n d / r s o f t wa r ee n v i r o n m e n t s m a y b e u s e d w i t h o u t d e p a r t i n g from t h e s c o p eo f t h e i n v e n t i o n .Q u e r y o p t i m i Z e r s h a v e a d d e d g r e a t b e n e ? t s t o a u t o m a t i co p e r a t i o n o f d a t a b a s e m a n a g e m e n t s y s t e m s . T h e s e o p t i m i Ze r s h a v e a l l o w e d d i f f e r e n t a c c e s s p l a n s t r a t e g i e s t o b e q u i c k l ye x p l o r e d s o t h a t an o p t i m a l s t r a t e g y can be i d e n t i ? e d ands e l e c t e d t o perform an SQL t a t e m e n t . I n a d d i t i o n , t h e r e a r e anumber o f d a t a b a s e m o n i t o r i n g t o o l s a v a i l a b l e t o c o l l e c t s t at i s t i c s a b o u t q u e r i e s a s t h e y e x e c u t e . H o w e v e r , t h e s e s t a t i s t i c sh a v e t y p i c a l l y b e e n u s e f u l o n l y t o s k i l l e d a d m i n i s t r a t o r s w h ocan i n t e r p r e t t h e s t a t i s t i c s and u s e them t o h e l p t u n e a d a t ab a s e . Embodiments o f t h e p r e s e n t i n v e n t i o n c o n t e m p l a t eu s i n g t h e d a t a c o l l e c t e d by a t a b a s e m o n i t o r i n g t o o l s t o a u t om a t i c a l l y a l l o w a d a t a b a s e t o t u n e i t s e l f by p e r m i t t i n g t h eq u e r y o p t i m i Z e r o u t i l i Z e t h e p e r f o r m a n c e s t a t i s t i c s c o l l e c t e dwhen e n e r a t i n g a q u e r y a c c e s s p l a n . T y p i c a l q u e r y o p t i m i Ze r s h a v e r e l a t i v e l y r o b u s t p e r f o r m a n c e a n d s u c c e s s f u l l yc h o o s e a n o p t i m a l a c c e s s p l a n t h e m a j o r i t y o f t h e t i m e ; h o we v e r , i n c e r t a i n i n s t a n c e s , t h e q u e r y o p t i m i Z e r m a y h a v e d i f? c u l t y i n s e l e c t i n g t h e b e s t a c c e s s p l a n . F o r e x a m p l e , t h emore complex t h e WHERE l a u s e t h a t ? l t e r s t h e s e l e c t i o n o frows of t a b l e , t h e more i f ? c u l t y t h e q u e r y o p t i m i Z e r h a s i ns e l e c t i n g t h e b e s t a c c e s s p l a n . A l s o , when m u l t i p l e ? l e s o rt a b l e s ) a r e i n v o l v e d i n a q u e r y , an o p t i m i Z e r m a y have d i ? ic u l t y i n s e l e c t i n g a n e ? i c i e n t a c c e s s p l a n . By u s i n g p a s tperformance s t a t i s t i c s a b o u t h o w a s i m i l a r a c c e s s p l a n a c t ua l l y p e r f o r m e d , t h e q u e r y o p t i m i Z e r may b e p r e v e n t e d f r o ms e l e c t i n g a p o o r p e r f o r m i n g a c c e s s p l a n t h a t o t h e r w i s ea p p e a r s t o b e t h e o p t i m a l p l a n .

    The y p e o f a t a t h a t can be o l l e c t e d by d a t a b a s e monitori s l r g e a n d v a r i e d . The e x e m p l a r y e m b o d i m e n t s d e s c r i b e dh e r e i n p r o v i d e s p e c i ? c e x a m p l e s o f p e r f o r m a n c e s t a t i s t i c st h a t m a y be used t o a f f e c t which a c c e s s p l a n an o p t i m i Z e rs e l e c t s . H o w e v e r , t h e p r e s e n t i n v e n t i o n a l s o c o n t e m p l a t e su s i n g o t h e r s p e c i ? c p e r f o r m a n c e s t a t i s t i c s t o a s s i s t t h e q u e r yo p t i m i Z e r . Commonly s e d p e r f o r m a n c e s t a t i s t i c s i n c l u d e ? l es i Z e , memory s i Z e , p r o c e s s o r s p e e d , number o f p r o c e s s o r sa v a i l a b l e , t h e SQL t a t e m e n t w i t h p a r a m e t e r s r e p l a c e d ) , t y p eo f SQL o p e r a t i o n , number o f row u p d a t e d , i n s e r t e d , o rd e l e t e d , number o f r o w s f e t c h e d , e l a p s e d t i m e f o r t h i s o p e r at i o n , a c c e s s p l a n r e b u i ld c o d e , t a b l e n a m e , j o i n ? e l d s , e s t im a t e d c o m p l e t i o n t i m e , e s t i m a t e I / O o p e r a t i o n s , number o fr o w s i n t h e t a b l e , i n d e x n a m e , h a s h u s e d , h o s t v a r i a b l e s , j o i np o s i t i o n , j o i n m e t h o d , j o i n t y p e , e t c .

    I n g e n e r a l , F I G . 3 i l l u s t r a t e s a ?owchart o f an exemplaryembodiment o f t h e p r e s e n t i n v e n t i o n . I n s t e p 3 0 2 , SQL t a t e

  • 8/13/2019 Us 8346761

    10/11

    US 8 , 3 4 6 , 7 6 1 B27

    m e n t s a r e e x e c u t e d a n d d u r i n g e x e c u t i o n , p e r f o r m a n c e s t at i s t i c s r e l a t i n g t o e a c h SQL s t a t e m e n t a r e t r a c k e d andr e c o r d e d . The performance s t a t is t i c s a r e maintained n a mann e r t h a t i s a c c e s s i b l e b y h e q u e r y o p t i m i z e r . When neW SQLs t a t e m e n t i s r e c e i v e d i n s t e p 3 0 4 , t h e q u e r y o p t i m i Z e r b e g i n st o g e n e r a t e a n a c c e s s p l a n , i n s t e p 3 0 6 . As a r t o f d e v e l o p i n gt h e a c c e s s p l a n , t h e q u e r y o p t i m i Z e r s e a r c h e s t h e p e r f o r m a n c es t a t i s t i c s , i n s t e p 3 0 8 , t o l o c a t e a t l e a s t one s i m i l a r SQLs t a t e m e n t t h a t Was p e r f o r m e d i n t h e p a s t . I n s t e p 3 1 0 , t h eperformance s t a t is t i c s of t h i s s t a t e m e n t , o r more than ones t a t e m e n t , a r e t h e n u s e d by t h e q u e r y o p t i m i Z e r When e v e lo p i n g t h e a c c e s s p l a n . The p t i m i Z e r m a y s e h i s i n f o r m a t i o nto f o r c e c e r t a i n r e s t r i c t i o n s When e v e l o p i n g an c c e s s p l a n o rmay se t h i s information t o s e l e c t betWeen d i f f e r e n t a c c e s sp l a n s t h a t a r e a v a i l a b l e f o r t h e p a r t i c u l a r SQL s t a t e m e n t .

    F I G . 4 i l l u s t r a t e s one exemplary u s e o f c e r t a i n p e r f o rm an ce s t a t i s t i c s of t h e d a t a b a s e monitor t o a s s i s t t h e queryo p t i m i Z e r i n s e l e c t i n g a n a c c e s s p l a n . A u e r y o p t i m i Z e rt y p i c a l l y m a i n t a i n s a l i s t o f a c c e s s p l a n s t h a t h a v e been r ev i o u s l y e x e c u t e d . T h u s , When a n SQL t a t e m e n t i s encount e r e d , t h e q u e r y o p t i m i Z e r s e a r c h e s t s c a c h e o f l a n s t o d e t e rmine if i t needs t o b u i l d an a c c e s s p l a n from s c r a t c h o rWhether i t can r e - u s e an a c c e s s p l a n i t h a s p r e v i o u s l y b u i l t .HoWever, an a c c e s s p l a n f o r a p a r t i c u l a r SQL t a t e m e n t m a yn o t be found i n t h e cache if t h e cache a c t s a s a FIFO b u f f e rW i t h l i m i t e d s i Z e o r i f t h e c a c h e i s i n v o l a t i l e m e m o r y t h a te x i s t s o n l y d u r i n g t h e c u r r e n t s e s s i o n o f t h e q u e r y o p t i m i Z e r .S i m i l a r l y , d u r i n g d y n a m i c SQL p e r a t i o n , t h e q u e r y a c c e s sp l a n s a r e n o t s a v e d a s t h e y a r e e x e c u t e d . HoWever, t h e d a t ab a s e monitor s t o r e s a n o n - v o l a t i l e r e c o r d of p r e v i o u s l ye x e c u t e d a c c e s s p l a n s a n d , t h e r e f o r e , p r o v i d e s a n a d d i t i o n a ls o u r c e o f i n f o r m a t i o n f o r t h e q u e r y o p t i m i z e r .

    I n s t e p 4 0 2 , t h e q u e r y o p t i m i Z e r i d e n t i ? e s t h e SQL t a t ement and e t e r m i n e s , i n s t e p 4 0 4 , W h e t h e r a n e x i s t i n g a c c e s sp l a n , c u r r e n t l y m a i n t a i n e d b y h e q u e r y p t i m i Z e r , i s a v a i l a b l ef o r t h e q u e r y . I f s o , t h e n t h a t a c c e s s p l a n i s u s e d , i n s t e p 4 0 6 ,t o p e r f o r m t h e q u e r y .

    I f t h e q u e r y o p t i m i Z e r c a n n o t l o c a t e a p r e v i o u s l y i m p l emented q u e r y a c c e s s p l a n , t h e n i t s e a r c h e s , i n s t e p 4 0 8 , t h er e c o r d s of t h e d a t a b a s e monitor f o r a s i m i l a r q u e r y o r SQLs t a t e m e n t . One o f o r d i n a r y s k i l l W i l l r e c o g n i Z e t h a t t h e r e a r ea v a r i e t y o f Ways t o measure s i m i l a r i t y betWeen q u e r i e s . Theq u e r i e s may b e c o m p a r e d on h e i r SQL s y n t a x , t h e i r JOINv a r i a b l e s , t h e i r WHERE l a u s e s , t h e i r h o s t v a r i a b l e s , a n do t h e r c h a r a c t e r i s t i c s . I f t h e p r e s e n t SQL u e r y i s s i m i l a r t o as t o r e d q u e r y , t h e n t h e q u e r y o p t i m i Z e r r e t r i e v e s o t h e r p e r f o rmance s t a t i s t i c s a b o u t t h e s t o r e d query from t h e d a t a b a s em o n i t o r r e c o r d s , i n s t e p 4 1 0 .

    I n s t e p 4 1 2 , t h e p e r f o r m a n c e s t a t i s t i c s o f t h e s t o r e d q u e r ya r e o p t i o n a l l y c h e c k e d t o v e r i f y t h a t t p e r f o r m e d t h e q u e r y a se s t i m a t e d o r W i t h t h e e s t i m a t e d number o f I / O o p e r a t i o n s .A l t e r n a t i v e l y , t h e p e r f o r m a n c e s t a t i s t i c s c a n b e u s e d t o d e t e rmine t h e number of roWs f e t c h e d a s compared o t h e numberofroWs p d a t e d . T h i s s t a t i s t i c m a y be used o d e t e r m i n e i f t h eSELECT c l a u s e i s s u ? i c i e n t l y ? l t e r i n g r e c o r d s a c t e d on byt h e WHERE l a u s e . The u r p o s e o f t h e d e t e r m i n a t i o n i n s t e p412 s t o i d e n t i f y W h e t h e r t h e a c c e s s p l a n t r a c k e d W i t h i n t h ed a t a b a s e monitor s one t h a t performed s u f ? c i e n t l y W e l l s o a sto recommend t t o t h e q u e r y o p t i m i Z e r .

    From t h e i n f o r m a t i o n i n t h e d a t a b a s e m o n i t o r r e c o r d s , t h eq u e r y o p t i m i Z e r c a n be f o r c e d , i n s t e p 4 1 4 , t o u s e c e r t a i ni m p l e m e n t a t i o n s t o g e n e r a t e a n a c c e s s p l a n e . g . , j o i n o r d e r s ,i n d e x e s , e t c . ) i n s t e a d o f e n e r a t i n g t h e n t i r e a c c e s s p l a n f r o ms c r a t c h . I n s t e p 4 1 6 , t h e n , t h i s a c c e s s p l a n i s e x e c u t e d toi m p l e m e n t t h e q u e r y .

    F I G . 5 i l l u s t r a t e s a ?owchart o f a n o t h e r exemplary use ofp e r f o r m a n c e s t a t i s t i c s b y a q u e r y o p t i m i Z e r i n a c c o r d a n c e

    20

    25

    30

    35

    40

    45

    50

    55

    60

    6 5

    8W i t h t h e p r i n c i p l e s o f t h e p r e s e n t i n v e n t i o n . I n s t e p 5 0 2 , t h eq u e r y o p t i m i Z e r r e c e i v e s a n SQL s t a t e m e n t a n d i d e n t i ? e s , i ns t e p 5 0 4 , a n a c c e s s p l a n t h a t had p r e v i o u s l y been u s e d t oi m p l e m e n t t h i s SQL s t a t e m e n t . I n s t e p 5 0 6 , t h e q u e r y o p t imiZer can t h e n s e a r c h f o r a r e c o r d i n t h e d a t a b a s e monitor ofa p r e v i o u s SQL s t a t e m e n t t h a t a l s o u s e d t h i s a c c e s s p l a n .From h i s r e c o r d , a d e t e r m i n a t i o n i s m a d e , i n s t e p 5 0 8 , a b o u thoW W e l l t h e a c c e s s p l a n p e r f o r m e d t h e SQL s t a t e m e n t . F o re x a m p l e , t h e e s t i m a t e d I / O o p e r a t i o n s c a n b e c o m p a r e da g a i n s t t h e a c t u a l I / O o p e r a t i o n s o r t h e e s t i m a t e d c o m p l e t i o nt i m e c a n be compared o t h e a c t u a l c o m p l e t i o n t i m e . I n a d d it i o n , o t h e r p e r f o r m a n c e c h a r a c t e r i s t i c s c a n b e compared t oone a n o t h e r to determine if t h e a c c e s s p l a n performed a si n t e n d e d . I f t h e p e r f o r m a n c e o f t h e a c c e s s p l a n Was beloWa c c e p t a b l e l e v e l s , t h e n t h e q u e r y o p t i m i Z e r f o r c e s r e - o p t i m iZ a t i o n o f t h e a c c e s s p l a n f o r t h i s SQL s t a t e m e n t , i n s t e p 5 1 0 .I f t h e a c c e s s p l a n d i d p e r f o r m a d e q u a t e l y , t h e n t h e q u e r yo p t i m i Z e r may i m p l e m e n t t h e q u e r y p l a n a s i t s t a n d s , i n s t e p5 1 2 .

    I f r e - o p t i m i Z a t i o n i s s e l e c t e d , t h e n t h e e s t i m a t e d r u n t i m ef o r t h e o r i g i n a l a c c e s s p l a n may b e i n c r e a s e d , i n s t ep 5 1 4 , t or e ? e c t t h e d i s c o v e r y t h a t t h e p r e v i o u s e s t i m a t e d r u n t i m ep r o v e d t o b e t o o s h o r t . I n t h i s W a y , t h e o r i g i n a l a c c e s s p l a nbecomes e s s a t t r a c t i v e t o t h e q u e r y o p t im i Z e r When h e q u e r yo p t i m i Z e r s s e l e c t i n g from among i f f e r e n t a c c e s s p l a n s f o r ap a r t i c u l a r q u e r y i n t h e f u t u r e . Even f t h e o r i g i n a l a c c e s s p l a ni s s e l e c t e d , t h e q u e r y o p t i m i Z e r may u t i l i Z e t h e h i s t o r i c a lr e c o r d s o f t h e d a t a b a s e m o n i t o r t o l e a r n t h e c l o s e s t e s t i m a t e dr u n t i m e f o r a p a r t i c u l a r a c c e s s p l a n and a d j u s t them a c c o r di n g l y .

    A n o t h e r a r e a Where e m p i r i c a l p e r f o r m a n c e s t a t i s t i c s c a nb e u s e d by a q u e r y o p t i m i Z e r t o i m p r o v e g e n e r a t i o n o f a na c c e s s p l a n i s r e l a t e d t o d a t a s k e W . The h y s i c a l a r r a n g e m e n to f d a t a on d i f f e r e n t d e v i c e s a f f e c t s t h e p e r f o r m a n c e o f d a t ab a s e o p e r a t i o n s . F o r e x a m p l e , i f a p a r t i c u l a r q u e r y r e s u l t s i na c c e s s i n g d a t a t h a t i s randomly s c a t t e r e d o v e r a v a r i e t y o fd i f f e r e n t d e v i c e s , t h e n a l a r g e p o r t i o n o f t h e I / O o p e r a t i o n smay ccur i n p a r a l l e l . I f t h e d a t a t o be a c c e s s e d i s concent r a t e d o n one o r j u s t a feW d e v i c e s , then /O p e r a t i o n s occurm a i n l y s e r i a l l y a n d p e r f o r m an c e s d e g r a d e d . O t h e r d a t a s k e Ws i t u a t i o n s m a y x i s t Where o n e p a r t i c u l a r d e v i c e i s e s p e c i a l l ysloW such t h a t any q u e r y p l a n t h a t a c c e s s t h a t d e v i c e r u n sm u c h l o W e r e . g . , 2 5 t o 1 0 0 t i m e s ) s l o W e r t h a n a v e r a g e q u e r yp l a n s . I n l a r g e d a t a W a r e h o u s e s , a d e v i c e m a y b e a p h y s i c a ld e v i c e o r a l o g i c a l p a r t i t i o n . F o r e x a m p l e , a d e v i c e m a y bep a r t i t i o n t h a t i s s t r i p e d a c r o s s m u l t i p l e p h y s i c a l d r i v e s . D a t askeW r e f e r s t o t h e g e n e r a l c o n d i t i o n i n Which t h e p h y s i c a lmanner i n Which t h e d a t a i s s t o r e d a d v e r s e l y a f f e c t s t h e p e rf o r m a n c e o f p e r f o r m i n g c e r t a i n I / O p e r a t i o n s .

    The ?owchart o f F I G . 6 i l l u s t r a t e s one exemplary methodf o r a q u e r y o p t i m i Z e r t o c o n s i d e r d a t a skeW When e l e c t i n g ana c c e s s p l a n f o r i m p l e m e n t i n g a n SQL s t a t e m e n t . I n s t e p 6 0 2 ,t h e d a t a b a s e m o n i t o r i s q u e r i e d t o i d e n t i f y Which h o s t v a r ia b l e s a r e i n v o l v e d i n q u e r y p l a n s t h a t e x e c u t e d x t i m e s s l o W e rt h a n i t s e s t i m a t e d run t i m e Where x m a y be a v a r i e t y ofnumbers s u c h a s , b u t n o t l i m i t e d t o , betWeen 2 5 - 1 0 0 ) . T h e s eh o s t v a r i a b l e s a r e i d e n t i ? e d a s h o s t v a r i a b l e t h a t i n v o l v e d a t as k e W . I n s t e p 6 0 4 , t h e q u e r y o p t i m i Z e r r e c e i v e s a n SQL t a t ement and e g i n s g e n e r a t i o n o f a n a c c e s s p l a n i n s t e p 6 0 6 . Asp a r t o f t h e g e n e r a t i o n o f t h e a c c e s s p l a n , t h e q u e r y o p t i m i Z e rd e t e r m i n e s , i n s t e p 6 0 8 , i f t h e c u r r e n t SQL t a t e m e n t i n c l u d e sone or m o re host a r i a b l e s t h a t have been identi?ed a s involvi n g d a t a s k e W . I f s o , t h e n t h e q u e r y o p t i m i Z e r can f o r c e ar e - o p t i m i Z a t i o n i n s t e p 610 t o e n s u r e a neW a c c e s s p l a n i sg e n e r a t e d from s c r a t c h . O t h e r W i s e , a c u r r e n t a c c e s s p l a n canb e e x e c u t e d , i n s t e p 6 1 2 , W i t h o u t r e - o p t i m i Z a t i o n , i f a v a i l a b l e .

  • 8/13/2019 Us 8346761

    11/11

    US 8 , 3 4 6 , 7 6 1 B2The method e s c r i b e d W i t h r e l a t i o n t o F I G . 6 i s p a r t i c u l a r l y

    u s e f u l When h e d a t a b a s e management s y s t e m i s o p e r a t i n g i na m o d e k n o w n a s r e u s a b l e open d a t a p a t h ODP) mode. TheODP s a d a t a s t r u c t u r e Within an access plan t h a t de?nes ana c t i v e p a t h t h r o u g h W h i c h d a t a i s r e a d . I n r e u s a b l e ODPmode, t h e ODP s k e p t open e v e n When t h e SQL q u e r y t h a tr e q u e s t e d t h e p a t h i s c l o s e d . T h i s s p e e d s u p d a t a a c c e s s t h en e x t t i m e t h e p a t h i s n e e d e d . R e u s a b l e ODP ode i m p r o v e sp e r f o r m a n c e b u t i s p a r t i c u l a r l y s u s c e p t i b l e t o p e r f o r m a n c ed e g r a d a t i o n due t o d a t a s k e W . T h u s , i f a q u e r y i n r e u s a b l eODP o d e r e f e r e n c e s a s e t of o s t v a r i a b l e s t h a t have beeni d e n t i ? e d a s i n v o l v i n g d a t a s k e W , i t i s p a r t i c u l a r l y a d v a n t ageous t o e x i t t h e r e u s a b l e ODP ode and f o r c e a r e - o p t i m iZ a t i o n o f t h e q u e r y . I f t h i s a t t e m p t a t r e - o p t i m i Z a t i o n d o e s n o tr e s u l t i n any i m p r o v e m e n t s , t h e n h i s s e t o f o s t v a r i a b l e s canbe marked a s e s p e c i a l l y harmful s o t h a t i n t h e f u t u r e no timeo r e f f o r t i s W a s t e d t o f o r c e r e - o p t i m i Z a t i o n o f q u e r i e s t h a tr e f e r e n c e t h i s s e t of o s t v a r i a b l e s .

    A n o t h e r p e r f o r m a n c e t a t i s t i c t h a t i s p e r i p h e r a l l y r e l a t e d od a t a skeW i n v o l v e s information about When t a b l e o r ? l e Wasr e - o r g a n i Z e d . R e - o r g a n i Z a t i o n o f a ? l e c h a n g e s i t s p h y s i c a ll a y o u t o n h e d i f f e r e n t s t o r a g e d e v i c e s on Which a d a t a b a s e i si m p l e m e n t e d a n d i m p l i c a t e s W h a t i n d e x may i m p r o v e ? l ea c c e s s p e r f o r m a n c e . T h u s , q u e r y a c c e s s p l a n s t h a t e x e c u t e db e f o r e a ? l e Was r e - o r g a n i Z e d may, o r may o t , be t h e b e s ta c c e s s p l a n t o implement an SQL t a t e m e n t . T h u s , t h e q u e r yo p t i m i Z e r , When e s t i m a t i n g l / O o p e r a t i o n s o r When e v a l u a ti n g e s t i m a t e d r u n t i m e s , i n o r d e r t o s e l e c t an a c c e s s p l a n , m a ya l s o c o n s i d e r Whether a t a b l e o r ? l e h a s been r e - o r g a n i Z e dWhen d e t e r m i n i n g hoW much W e i g h t t o a s s i g n t h e d i f f e r e n tp e r f o r m a n c e s t a t i s t i c s .

    A c c o r d i n g l y , a s y s t e m and method a s been e s c r i b e d t h a tp e r m i t s a q u e r y o p t i m i Z e r o a u t o m a t i c a l l y c o n s i d e r e m p i r i c a l

    20

    25

    30

    1 0p e r f o r m a n c e s t a t i s t i c s When s e l e c t i n g an a c c e s s p l a n f o r a nSQL t a t e m e n t . V a r i o u s m o d i ? c a t i o n s m a y be m ade t o t h ei l l u s t r a t e d e m b o d i m e n t s W i t h o u t d e p a r t i n g f r o m t h e s p i r i t a n ds c o p e o f t h e i n v e n t i o n . T h e r e f o r e , t h e i n v e n t i o n l i e s i n t h ec l a i m s h e r e i n a f t e r a p p e n d e d .

    What s c l a i m e d i s :1 . A ethod f o r g e n e r a t i n g an a c c e s s p l a n , t h e method

    c o m p r i s i n g t h e s t e p s o f :m a i n t a i n i n g i n n o n - v o l a t i l e memory r e s p e c t i v e s e t o f a s t

    p e r f o r m a n c e s t a t i s t i c s f o r e a c h o f a p l u r a l i t y o f p r e v io u s l y e x e c u t e d d a t a b a s e q u e r i e s ;

    i d e n t i f y i n g a s e t of o s t v a r i a b l e s r e f e r e n c e d W i t h i n t h o s er e s p e c t i v e s e t s o f p a s t p e r f o r m a n c e s t a t i s t i c s t h a t r e l a t et o d a t a s k e W p e r f o r m a n c e d e g r a d a t i o n ; a n d

    f o r c i n g r e - o p t i m i Z a t i o n t o g e n e r a t e and s t o r e a neW a c c e s sp l a n f o r a c u r r e n t SQL t a t e m e n t i f t h e c u r r e n t d a t a b a s equery i n c l u d e s one or m o re host v a r i a b l e s Within thei d e n t i ? e d s e t of o s t v a r i a b l e s .2 . The method o f c l a i m 1 , f u r t h e r c o m p r i s i n g t h e s t e p o f :

    determining if a c u r r e n t database query i n c l u d e s one o rmore of h e i d e n t i ? e d s e t of o s t v a r i a b l e s .3 . The method o f c l a i m 1 , W h e r e i n t h e s t e p o f i d e n t i f y i n g

    f u r t h e r i n c l u d e s t h e s t e p o f :i d e n t i f y i n g a s e t o f h o s t v a r i a b l e s r e f e r e n c e s W i t h i n t h o s er e s p e c t i v e s e t s o f p a s t p e r f o r m a n c e s t a t i s t i c s t h a te x e c u t e d s l o W e r t h a n e s t i m a t e d .

    4 . The method o f c l a i m 3 , W h e r e i n t h e s t e p o f i d e n t i f y i n gf u r t h e r i n c l u d e s t h e s t e p o f :

    i d e n t i f y i n g t h e s e t o f o s t v a r i a b l e s r e f e r e n c e s W i t h i n t h o s er e s p e c t i v e s e t s o f p a s t p e r f o r m a n c e s t a t i s t i c s t h a te x e c u t e d betWeen 2 5 and 1 0 0 t i m e s s l o W e r t h a n e s t im a t e d .