SlideShare a Scribd company logo
1 of 42
Download to read offline
<Insert Picture Here>




Why “why” (or it depends) is probably the right
answer
Thomas Kyte
http://asktom.oracle.com/
Who am I

                 • Been with Oracle since 1993
                 • User of Oracle since 1987
                 • The “Tom” behind AskTom in
                   Oracle Magazine
                    www.oracle.com/oramag
                 • Expert Oracle Database
                   Architecture
                 • Effective Oracle by Design
                 • Expert One on One Oracle
                 • Beginning Oracle


           What we know, shapes how we do things...
Why the right first answer is probably
                                 “Why, what is your goal”
                           (and the second one is “it depends”)


Copyright Kyte Inc. 2005
What prompted me to think about this

    QUOTE

    its funny how you sometimes have to explain the question in order to
    get the the answer.

    It's not "funny", IMHO. It's rude and unproductive for people to
    assume that you don't know what you are doing. For example, this
    question is none of XXX’s business, and it assumes that you don't
    have enough skill to follow standard DBA procedures and best-
    practices
        .
    This person came for answers and suggestions, not to play 20-
    questions with some anonymous person.

    If you want to "ask" questions, please feel free to start a thread. . .
Copyright Kyte Inc. 2005
So, what is wrong with that

   • Just about everything



   • Let’s ask some questions




Copyright Kyte Inc. 2005
How do I reorg a table?

   • You could answer with any of the following:

              –     Alter table T move, rebuild indexes
              –     Export/Import
              –     Create table as select, index, grant, constrain
              –     DBMS_REDEFINITION
              –     Alter table shrink (10g)
              –     And maybe more.

   • So, why is “why, what is the goal” the only right
     answer?
Copyright Kyte Inc. 2005
How do I reorg a table?

   • You Alter table T move, rebuild indexes

              –     And say they did that, what did they get?
                     • Took 2 hours of downtime (big table, lots of indexes)
                     • Cost $$$, they could have been doing something truly
                       productive
                     • Did they achieve their goal? Not in this case, their perceived
                       problem was chained rows (say 1,000 of them)
                     • After the reorg, they still had 1,000 chained rows!


   • We need to ask “WHY”, what is the goal.


Copyright Kyte Inc. 2005
How do I create a table in a stored procedure

   • You could answer

              –     Get CREATE TABLE granted directly to you, not via a
                    role. Use EXECUTE IMMEDIATE ‘create table ’

              –     Or, you could answer “why, what is the goal?”




Copyright Kyte Inc. 2005
How do I create a table in a stored procedure

   • Why is Why the right answer?

              –     They were porting from SQL Server.
              –     They had years of database experience.
              –     Just not with Oracle.
              –     Dropping and Creating tables in PL/SQL is not the
                    correct approach in Oracle.
              –     We need to tell them How in Oracle.
              –     They are not stupid, they just don’t know something yet
              –     We are not presumptuous or rude, just responsible

Copyright Kyte Inc. 2005
How do I reorg a 50gig database
    At a given customer site, I must reorganize a 50 Gigs Prod DB in a
    single day.

    Note that I do not know the environment yet (I am replacing somebody
    leaving on vacation without providing any analysis report. This guy only
                                 re-
    told this DB is bad, we must re-organize it and left on vacation...).

    I only know the DB is running on a Windows server, the 50 Gigs DB is
    mission-critical (hosting the PeopleSoft Financials suite), the DB is said
    to be highly-fragmented at the tablespace-levels and highly chained at
    the table-levels but no bad-perf issue has been apparently reported.

     I do not have disk space to create a new db aside the current one, I only
    have One Day to successfully carry out the whole thing. What would be
    the right approach ? Keeping in mind, not to loose anything on the
    way ... (i.e., low risk). What would be the best strategy ?
Copyright Kyte Inc. 2005
How do I reorg a 50gig database

   • I asked “why”, “what is the goal”
   • Answer:
              –     Tablespace fragmented as reported by Toad
              –     Chained rows, must get rid of chained rows

   • Turns out peoplesoft uses lots of longs, won’t matter how
     many times you rebuild will it.
   • Fragmented tablespace – so what? 1 extent or 500 extents.
     So what? They don’t drop/truncate, so “so what”

   • Only answer is “don’t even think about doing this”. What
     would have happened had I just answered the question!

Copyright Kyte Inc. 2005
It makes it clear

   • People asking questions have a lot of inside
     information
   • People receiving the question don’t
   • We need to communicate from person A to person
     B
   • And if we ass-u-me the person asking the question
     has some in depth knowledge – and they don’t,
     we’ve just really ‘hosed’ them.
   • It would be irresponsible to not justify their
     questions

Copyright Kyte Inc. 2005
Why ask Why?

   • Because most of the time you won’t have to
     actually answer after that!
              –     When you find out why, the answer becomes “oh, you
                    don’t need to do that”


   • Because it is the only responsible thing to do
              –     You don’t know how much the person on the other end
                    of the ethernet cable actually knows


   • Because it is the only way to get the best answer

Copyright Kyte Inc. 2005
It
                depends
                           If Why isn’t the right answer, then this
                                       one probably is

                             What is the best way questions

Copyright Kyte Inc. 2005
ops$tkyte%ORA11GR2> with
 2   players as
 3   ( select cast( 'P'||rownum as varchar2(2) ) username
 4          from all_objects
 5         where rownum <= 8),
 6   weeks as
 7   ( select rownum week
 8          from all_objects
 9         where rownum <= 7 ),
10   data as
11   ( select username,
12               week,
13               row_number() over (partition by week order by rnd) rn
14         from ( select username, week, dbms_random.random rnd
15                   from players, weeks
16               )
17   )
18   select *
19       from data
20       pivot( max(username) for rn in (1,2,3,4,5,6,7,8) )
21       order by week
22   /
ops$tkyte%ORA11GR1> with
 2   players as
 3   ( select cast( 'P'||rownum as varchar2(2) ) username
 4         from all_objects
 5         where rownum <= 8),
 6   …
18   select *
19       from data
20       pivot( max(username) for rn in (1,2,3,4,5,6,7,8) )
21       order by week
22   /


         WEEK 1   2   3   4   5   6   7   8
---------- -- -- -- -- -- -- -- --
            1 P4 P5 P8 P3 P2 P1 P6 P7
            2 P5 P8 P7 P2 P6 P1 P4 P3
            3 P8 P3 P6 P7 P4 P5 P2 P1
            4 P5 P2 P3 P8 P6 P1 P7 P4
            5 P6 P8 P1 P7 P5 P2 P4 P3
            6 P4 P8 P7 P6 P2 P1 P5 P3
            7 P6 P8 P2 P1 P3 P7 P4 P5


7 rows selected.
Best Practices defined –
Consensus of expert opinions, based       <Insert Picture Here>

on actual customer experiences in
practice.
Lessons learned.
Proven practices associated with a
particular usage profile.
Baseline configuration rules -
prerequisite to tuning.
                                     Sounds all good
Best Practices – It is easy with Best
Practices to forget that once a            <Insert Picture Here>

practice has been branded as "Best",
that it may represent certain tradeoffs
and may involve noteworthy
downside potential. It is also easy to
forget the context for which any
given practice was promoted as
"Best", and therefore apply it in some
inappropriate context.
           - Bob Sneed, Sun Microsystems
Bryn Llewellyn on Best Practices
Prescribing best practice principles for programming
any 3GL is phenomenally difficult. One of the hardest
challenges is the safety of the assumption that the
reader starts out with these qualities



 • Has chosen common from education.(Howwell- can
   Knows Oracle toinsidesenseseveral others. else
   Can natural thefirst technical prose.excellent takes
   Requiresclassanegotiating mechanical systems.
        easy accessvisualize self
        received Database orskills. (Good code
        first excellenceclassinside out.
        an PL/SQL right parents. and with
        write excellent one
            ability   to out. coupled
   mentors...
   you write the requirements for your
   longer to write and test than bad code; managers
   developed verbal reasoning skills. code, write the
   test specifications, and discuss problems that arise
   want code delivered in aggressive timeframes.)
   along the way?)
<Insert Picture Here>
“What is the best way..?” –
Questions that begin and end
with that can drive you nuts.


If there was a universal best way to do something,
we would not have implemented the other ways



                              AskTom “What is The best way?”
<Insert Picture Here>                       Is there
                                                   a best way
                                      to do something – every
                                                        time?

    select          *
      from          t1, t2
     where          t1. id = t2. id
       and          t1.small_distinct = :x
• T1 is large, where small_distinct = :x returns much of the table
• T2 is large
<Insert Picture Here>                      Is there
                                                 a best way
                                    to do something – every
                                                      time?
select * from t1, t2
 where t1. id = t2. Id and t1.small_distinct = :x

HASH JOIN                        SELECT STATEMENT
   TABLE ACCESS FULL T1           NESTED LOOPS
   TABLE ACCESS FULL T2             TABLE ACCESS BY INDEX ROWID(T1)
                                     INDEX RANGE SCAN T1_IDX
                                    TABLE ACCESS BY INDEX ROWID(T2)
                                     INDEX UNIQUE SCAN T2_PK
<Insert Picture Here>                              Is there
                                                             a best way
                                                to do something – every
                                                                  time?
HASH JOIN                                   SELECT STATEMENT
   TABLE ACCESS FULL T1                      NESTED LOOPS
   TABLE ACCESS FULL T2                        TABLE ACCESS BY INDEX ROWID(T1)
                                                INDEX RANGE SCAN T1_IDX
                                               TABLE ACCESS BY INDEX ROWID(T2)
                                                INDEX UNIQUE SCAN T2_PK




   call           count              cpu    elapsed           disk               query
   Fetch          35227              5.63       9.32         23380               59350
   Fetch          35227        912.07       3440.70      1154555        121367981
<Insert Picture Here>                              Is there
                                                             a best way
                                                to do something – every
                                                                  time?
HASH JOIN                                   SELECT STATEMENT
   TABLE ACCESS FULL T1                      NESTED LOOPS
   TABLE ACCESS FULL T2                        TABLE ACCESS BY INDEX ROWID(T1)
                                                INDEX RANGE SCAN T1_IDX
                                               TABLE ACCESS BY INDEX ROWID(T2)
                                                INDEX UNIQUE SCAN T2_PK




   call           count              cpu    elapsed           disk               query
   Fetch                  1          4.55       5.16         12152               12456
   Fetch                  1          0.05       0.09              12               15
<Insert Picture Here>



It takes a context – It is also
easy to forget the context for
which any given practice was
promoted as "Best", and
therefore apply it in some
inappropriate context

    Indexes are ‘best’, everyone knows that
<Insert Picture Here>



It takes understanding too –
You need to take the facts,
coupled with your knowledge,

    How do I tune with tkprof
<Insert Picture Here>
                                                                          What can
                                                                   you do with this
                                                                      information?
select count(subobject_name) from big_table.big_table

COUNT(SUBOBJECT_NAME)
---------------------
               688256


call      count           cpu   elapsed      disk     query
total         4         99.36    262.11   1840758   1840800

Rows         Row Source Operation
        1    SORT AGGREGATE (cr=1840797 pr=1840758 pw=0 time=262104893 us)
128000000     TABLE ACCESS FULL BIG_TABLE (cr=1840797 pr=1840758 pw=0 time=384004887 us)


 Event waited on                                     Times     Max. Wait   Total Waited
db file scattered read                              14425          0.22         195.87
<Insert Picture Here>
                                             First, there
                                         are a bunch of
                                                 facts

• Query took a long time – if we make it fast
• We did a ton of physical IO – and that is slow
• We did a ton of logical IO – and that is not ‘free’
• There is a big difference between elapsed and cpu –
  we were waiting for something
• We can see our query and plan – we know the
  answer to the query
<Insert Picture Here>
                                                 There are
                                            things we have
                                            knowledge of

• We know the data (it is ours after all)
• How Oracle works (hopefully!)
<Insert Picture Here>                          What are
                                              some obvious
                                              things to think
                                                 about here?

• We needed a very small subset of the rows – 700k
  out of 128m
• The table looks well packed – simple math, divide
  IO’s (cr=1,840,797) by rows (128,000,000), about 70
  rows/block and given we know the average row width
  (it is our data after all ) that sounds nicely packed
  • What can we rule out now? Shrink and Rebuild
<Insert Picture Here>
                                                     What are
                                                 Some possible
                                                     options?

• Make full scan faster
  • Maybe by compressing the table
  • Maybe by including subobject_name in some index (to avoid
    the table)
• Remove Full Scan
  • We are interested in only 0.6% of the data
  • Maybe a new index would help
• Don’t do it or do it differently
<Insert Picture Here>                                In Real
                                                              Life it
                                                      Will be more
                                                       Complex

• It will be more complex in general
• But the process is the same
  •   Get facts
  •   Infer more facts
  •   Build your context!
  •   Rule things out
       • Ruling something out is as good as ruling something in
       • Many best practices will fall by the wayside here
Educated Incapacity – A                                 <Insert Picture Here>

     barrier to creative ideas can be
     experience, ‘the best way’
"This 'telephone' has too many shortcomings to be seriously
 considered as a means of communication. The device is inherently of
 no value to us.“ – Western Union internal memo, 1876.
" The concept is interesting and well-formed, but in order to earn better
 than a 'C,' the idea must be feasible.“ – Yale University management
 professor in response to Fred Smith's paper proposing reliable
 overnight delivery service. Smith went on to found Federal Express
 Corp.
Although experience is often valuable, it can be a liability in a search
 for creative ideas.
<Insert Picture Here>


So, What is the point?
<Insert Picture Here>


Continuous Rethinking
<Insert Picture Here>


Continuous Change
<Insert Picture Here>


Learn a new language – else
everything will look like a nail.


C, C++, PL/I, Rexx, Exec, JCL, SAS, Pascal,
Cobol, Java, Ada, PL/SQL, T-SQL, Prolog,
Lisp, Scheme, Various Assemblers, many SQL
dialects, many scripting languages,
<Insert Picture Here>


Don’t tune a query – tune a
process, an algorithm, the
entire approach.


Don’t fall into the sunk cost theory
<Insert Picture Here>


Always Question Everything –
in a non-annoying way of
course!


Question Authority
<Insert Picture Here>

Collaborate – Participate,
Network, Exchange ideas.


I learn something new every day about
Oracle – from the questions I get about
Oracle
<Insert Picture Here>




The Best Way
Thomas Kyte
http://asktom.oracle.com/
                             What we know, shapes how we do things...

More Related Content

Similar to [INSIGHT OUT 2011] A21 why why is probably the right answer(tom kyte)

Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012cobyst
 
Agile Development Overview (with a bit about builds)
Agile Development Overview (with a bit about builds)Agile Development Overview (with a bit about builds)
Agile Development Overview (with a bit about builds)David Benjamin
 
Coaching teams in creative problem solving
Coaching teams in creative problem solvingCoaching teams in creative problem solving
Coaching teams in creative problem solvingFlowa Oy
 
NATS - A new nervous system for distributed cloud platforms
NATS - A new nervous system for distributed cloud platformsNATS - A new nervous system for distributed cloud platforms
NATS - A new nervous system for distributed cloud platformsDerek Collison
 
Real World Performance - Data Warehouses
Real World Performance - Data WarehousesReal World Performance - Data Warehouses
Real World Performance - Data WarehousesConnor McDonald
 
Agile Estimation @ Lean Agile Manchester: Make Estimates Small!
Agile Estimation @ Lean Agile Manchester: Make Estimates Small!Agile Estimation @ Lean Agile Manchester: Make Estimates Small!
Agile Estimation @ Lean Agile Manchester: Make Estimates Small!Axelisys Limited
 
Bender kuszmaul tutorial-xldb12
Bender kuszmaul tutorial-xldb12Bender kuszmaul tutorial-xldb12
Bender kuszmaul tutorial-xldb12Atner Yegorov
 
Data Structures and Algorithms for Big Databases
Data Structures and Algorithms for Big DatabasesData Structures and Algorithms for Big Databases
Data Structures and Algorithms for Big Databasesomnidba
 
Life in the tech trenches (2015)
Life in the tech trenches (2015)Life in the tech trenches (2015)
Life in the tech trenches (2015)Julien SIMON
 
CTO Crunch avec Julien Simon, Viadeo
CTO Crunch avec Julien Simon, ViadeoCTO Crunch avec Julien Simon, Viadeo
CTO Crunch avec Julien Simon, ViadeoFrance Digitale
 
CFP workshop
CFP workshopCFP workshop
CFP workshopAmit Zur
 
Patella railsconf 2012
Patella railsconf 2012Patella railsconf 2012
Patella railsconf 2012Jeff Dwyer
 
Is That Normal? Behaviour Modelling On The Cheap
Is That Normal? Behaviour Modelling On The CheapIs That Normal? Behaviour Modelling On The Cheap
Is That Normal? Behaviour Modelling On The CheapMark Nunnikhoven
 
You shouldneverdo
You shouldneverdoYou shouldneverdo
You shouldneverdodaniil3
 
V10 getting the_job_outline_of_important_things
V10 getting the_job_outline_of_important_thingsV10 getting the_job_outline_of_important_things
V10 getting the_job_outline_of_important_thingsSadashiv_Dhulashetti
 
TDD: seriously, try it! 
TDD: seriously, try it! TDD: seriously, try it! 
TDD: seriously, try it! Nacho Cougil
 
Microsoft azure data fundamentals (dp 900) practice tests 2022
Microsoft azure data fundamentals (dp 900) practice tests 2022Microsoft azure data fundamentals (dp 900) practice tests 2022
Microsoft azure data fundamentals (dp 900) practice tests 2022SkillCertProExams
 
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018Mike Harris
 
Distributed processing of large graphs in python
Distributed processing of large graphs in pythonDistributed processing of large graphs in python
Distributed processing of large graphs in pythonJose Quesada (hiring)
 
Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...
Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...
Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...IDERA Software
 

Similar to [INSIGHT OUT 2011] A21 why why is probably the right answer(tom kyte) (20)

Clean code, Feb 2012
Clean code, Feb 2012Clean code, Feb 2012
Clean code, Feb 2012
 
Agile Development Overview (with a bit about builds)
Agile Development Overview (with a bit about builds)Agile Development Overview (with a bit about builds)
Agile Development Overview (with a bit about builds)
 
Coaching teams in creative problem solving
Coaching teams in creative problem solvingCoaching teams in creative problem solving
Coaching teams in creative problem solving
 
NATS - A new nervous system for distributed cloud platforms
NATS - A new nervous system for distributed cloud platformsNATS - A new nervous system for distributed cloud platforms
NATS - A new nervous system for distributed cloud platforms
 
Real World Performance - Data Warehouses
Real World Performance - Data WarehousesReal World Performance - Data Warehouses
Real World Performance - Data Warehouses
 
Agile Estimation @ Lean Agile Manchester: Make Estimates Small!
Agile Estimation @ Lean Agile Manchester: Make Estimates Small!Agile Estimation @ Lean Agile Manchester: Make Estimates Small!
Agile Estimation @ Lean Agile Manchester: Make Estimates Small!
 
Bender kuszmaul tutorial-xldb12
Bender kuszmaul tutorial-xldb12Bender kuszmaul tutorial-xldb12
Bender kuszmaul tutorial-xldb12
 
Data Structures and Algorithms for Big Databases
Data Structures and Algorithms for Big DatabasesData Structures and Algorithms for Big Databases
Data Structures and Algorithms for Big Databases
 
Life in the tech trenches (2015)
Life in the tech trenches (2015)Life in the tech trenches (2015)
Life in the tech trenches (2015)
 
CTO Crunch avec Julien Simon, Viadeo
CTO Crunch avec Julien Simon, ViadeoCTO Crunch avec Julien Simon, Viadeo
CTO Crunch avec Julien Simon, Viadeo
 
CFP workshop
CFP workshopCFP workshop
CFP workshop
 
Patella railsconf 2012
Patella railsconf 2012Patella railsconf 2012
Patella railsconf 2012
 
Is That Normal? Behaviour Modelling On The Cheap
Is That Normal? Behaviour Modelling On The CheapIs That Normal? Behaviour Modelling On The Cheap
Is That Normal? Behaviour Modelling On The Cheap
 
You shouldneverdo
You shouldneverdoYou shouldneverdo
You shouldneverdo
 
V10 getting the_job_outline_of_important_things
V10 getting the_job_outline_of_important_thingsV10 getting the_job_outline_of_important_things
V10 getting the_job_outline_of_important_things
 
TDD: seriously, try it! 
TDD: seriously, try it! TDD: seriously, try it! 
TDD: seriously, try it! 
 
Microsoft azure data fundamentals (dp 900) practice tests 2022
Microsoft azure data fundamentals (dp 900) practice tests 2022Microsoft azure data fundamentals (dp 900) practice tests 2022
Microsoft azure data fundamentals (dp 900) practice tests 2022
 
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
 
Distributed processing of large graphs in python
Distributed processing of large graphs in pythonDistributed processing of large graphs in python
Distributed processing of large graphs in python
 
Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...
Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...
Geek Sync | Breaking Bad Habits: Solutions for Common Query Antipatterns - Je...
 

More from Insight Technology, Inc.

グラフデータベースは如何に自然言語を理解するか?
グラフデータベースは如何に自然言語を理解するか?グラフデータベースは如何に自然言語を理解するか?
グラフデータベースは如何に自然言語を理解するか?Insight Technology, Inc.
 
Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~
Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~
Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~Insight Technology, Inc.
 
事例を通じて機械学習とは何かを説明する
事例を通じて機械学習とは何かを説明する事例を通じて機械学習とは何かを説明する
事例を通じて機械学習とは何かを説明するInsight Technology, Inc.
 
仮想通貨ウォレットアプリで理解するデータストアとしてのブロックチェーン
仮想通貨ウォレットアプリで理解するデータストアとしてのブロックチェーン仮想通貨ウォレットアプリで理解するデータストアとしてのブロックチェーン
仮想通貨ウォレットアプリで理解するデータストアとしてのブロックチェーンInsight Technology, Inc.
 
MBAAで覚えるDBREの大事なおしごと
MBAAで覚えるDBREの大事なおしごとMBAAで覚えるDBREの大事なおしごと
MBAAで覚えるDBREの大事なおしごとInsight Technology, Inc.
 
グラフデータベースは如何に自然言語を理解するか?
グラフデータベースは如何に自然言語を理解するか?グラフデータベースは如何に自然言語を理解するか?
グラフデータベースは如何に自然言語を理解するか?Insight Technology, Inc.
 
DBREから始めるデータベースプラットフォーム
DBREから始めるデータベースプラットフォームDBREから始めるデータベースプラットフォーム
DBREから始めるデータベースプラットフォームInsight Technology, Inc.
 
SQL Server エンジニアのためのコンテナ入門
SQL Server エンジニアのためのコンテナ入門SQL Server エンジニアのためのコンテナ入門
SQL Server エンジニアのためのコンテナ入門Insight Technology, Inc.
 
db tech showcase2019オープニングセッション @ 森田 俊哉
db tech showcase2019オープニングセッション @ 森田 俊哉 db tech showcase2019オープニングセッション @ 森田 俊哉
db tech showcase2019オープニングセッション @ 森田 俊哉 Insight Technology, Inc.
 
db tech showcase2019 オープニングセッション @ 石川 雅也
db tech showcase2019 オープニングセッション @ 石川 雅也db tech showcase2019 オープニングセッション @ 石川 雅也
db tech showcase2019 オープニングセッション @ 石川 雅也Insight Technology, Inc.
 
db tech showcase2019 オープニングセッション @ マイナー・アレン・パーカー
db tech showcase2019 オープニングセッション @ マイナー・アレン・パーカー db tech showcase2019 オープニングセッション @ マイナー・アレン・パーカー
db tech showcase2019 オープニングセッション @ マイナー・アレン・パーカー Insight Technology, Inc.
 
難しいアプリケーション移行、手軽に試してみませんか?
難しいアプリケーション移行、手軽に試してみませんか?難しいアプリケーション移行、手軽に試してみませんか?
難しいアプリケーション移行、手軽に試してみませんか?Insight Technology, Inc.
 
Attunityのソリューションと異種データベース・クラウド移行事例のご紹介
Attunityのソリューションと異種データベース・クラウド移行事例のご紹介Attunityのソリューションと異種データベース・クラウド移行事例のご紹介
Attunityのソリューションと異種データベース・クラウド移行事例のご紹介Insight Technology, Inc.
 
そのデータベース、クラウドで使ってみませんか?
そのデータベース、クラウドで使ってみませんか?そのデータベース、クラウドで使ってみませんか?
そのデータベース、クラウドで使ってみませんか?Insight Technology, Inc.
 
コモディティサーバー3台で作る高速処理 “ハイパー・コンバージド・データベース・インフラストラクチャー(HCDI)” システム『Insight Qube』...
コモディティサーバー3台で作る高速処理 “ハイパー・コンバージド・データベース・インフラストラクチャー(HCDI)” システム『Insight Qube』...コモディティサーバー3台で作る高速処理 “ハイパー・コンバージド・データベース・インフラストラクチャー(HCDI)” システム『Insight Qube』...
コモディティサーバー3台で作る高速処理 “ハイパー・コンバージド・データベース・インフラストラクチャー(HCDI)” システム『Insight Qube』...Insight Technology, Inc.
 
複数DBのバックアップ・切り戻し運用手順が異なって大変?!運用性の大幅改善、その先に。。
複数DBのバックアップ・切り戻し運用手順が異なって大変?!運用性の大幅改善、その先に。。 複数DBのバックアップ・切り戻し運用手順が異なって大変?!運用性の大幅改善、その先に。。
複数DBのバックアップ・切り戻し運用手順が異なって大変?!運用性の大幅改善、その先に。。 Insight Technology, Inc.
 
Attunity社のソリューションの日本国内外適用事例及びロードマップ紹介[ATTUNITY & インサイトテクノロジー IoT / Big Data フ...
Attunity社のソリューションの日本国内外適用事例及びロードマップ紹介[ATTUNITY & インサイトテクノロジー IoT / Big Data フ...Attunity社のソリューションの日本国内外適用事例及びロードマップ紹介[ATTUNITY & インサイトテクノロジー IoT / Big Data フ...
Attunity社のソリューションの日本国内外適用事例及びロードマップ紹介[ATTUNITY & インサイトテクノロジー IoT / Big Data フ...Insight Technology, Inc.
 
レガシーに埋もれたデータをリアルタイムでクラウドへ [ATTUNITY & インサイトテクノロジー IoT / Big Data フォーラム 2018]
レガシーに埋もれたデータをリアルタイムでクラウドへ [ATTUNITY & インサイトテクノロジー IoT / Big Data フォーラム 2018]レガシーに埋もれたデータをリアルタイムでクラウドへ [ATTUNITY & インサイトテクノロジー IoT / Big Data フォーラム 2018]
レガシーに埋もれたデータをリアルタイムでクラウドへ [ATTUNITY & インサイトテクノロジー IoT / Big Data フォーラム 2018]Insight Technology, Inc.
 

More from Insight Technology, Inc. (20)

グラフデータベースは如何に自然言語を理解するか?
グラフデータベースは如何に自然言語を理解するか?グラフデータベースは如何に自然言語を理解するか?
グラフデータベースは如何に自然言語を理解するか?
 
Docker and the Oracle Database
Docker and the Oracle DatabaseDocker and the Oracle Database
Docker and the Oracle Database
 
Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~
Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~
Great performance at scale~次期PostgreSQL12のパーティショニング性能の実力に迫る~
 
事例を通じて機械学習とは何かを説明する
事例を通じて機械学習とは何かを説明する事例を通じて機械学習とは何かを説明する
事例を通じて機械学習とは何かを説明する
 
仮想通貨ウォレットアプリで理解するデータストアとしてのブロックチェーン
仮想通貨ウォレットアプリで理解するデータストアとしてのブロックチェーン仮想通貨ウォレットアプリで理解するデータストアとしてのブロックチェーン
仮想通貨ウォレットアプリで理解するデータストアとしてのブロックチェーン
 
MBAAで覚えるDBREの大事なおしごと
MBAAで覚えるDBREの大事なおしごとMBAAで覚えるDBREの大事なおしごと
MBAAで覚えるDBREの大事なおしごと
 
グラフデータベースは如何に自然言語を理解するか?
グラフデータベースは如何に自然言語を理解するか?グラフデータベースは如何に自然言語を理解するか?
グラフデータベースは如何に自然言語を理解するか?
 
DBREから始めるデータベースプラットフォーム
DBREから始めるデータベースプラットフォームDBREから始めるデータベースプラットフォーム
DBREから始めるデータベースプラットフォーム
 
SQL Server エンジニアのためのコンテナ入門
SQL Server エンジニアのためのコンテナ入門SQL Server エンジニアのためのコンテナ入門
SQL Server エンジニアのためのコンテナ入門
 
Lunch & Learn, AWS NoSQL Services
Lunch & Learn, AWS NoSQL ServicesLunch & Learn, AWS NoSQL Services
Lunch & Learn, AWS NoSQL Services
 
db tech showcase2019オープニングセッション @ 森田 俊哉
db tech showcase2019オープニングセッション @ 森田 俊哉 db tech showcase2019オープニングセッション @ 森田 俊哉
db tech showcase2019オープニングセッション @ 森田 俊哉
 
db tech showcase2019 オープニングセッション @ 石川 雅也
db tech showcase2019 オープニングセッション @ 石川 雅也db tech showcase2019 オープニングセッション @ 石川 雅也
db tech showcase2019 オープニングセッション @ 石川 雅也
 
db tech showcase2019 オープニングセッション @ マイナー・アレン・パーカー
db tech showcase2019 オープニングセッション @ マイナー・アレン・パーカー db tech showcase2019 オープニングセッション @ マイナー・アレン・パーカー
db tech showcase2019 オープニングセッション @ マイナー・アレン・パーカー
 
難しいアプリケーション移行、手軽に試してみませんか?
難しいアプリケーション移行、手軽に試してみませんか?難しいアプリケーション移行、手軽に試してみませんか?
難しいアプリケーション移行、手軽に試してみませんか?
 
Attunityのソリューションと異種データベース・クラウド移行事例のご紹介
Attunityのソリューションと異種データベース・クラウド移行事例のご紹介Attunityのソリューションと異種データベース・クラウド移行事例のご紹介
Attunityのソリューションと異種データベース・クラウド移行事例のご紹介
 
そのデータベース、クラウドで使ってみませんか?
そのデータベース、クラウドで使ってみませんか?そのデータベース、クラウドで使ってみませんか?
そのデータベース、クラウドで使ってみませんか?
 
コモディティサーバー3台で作る高速処理 “ハイパー・コンバージド・データベース・インフラストラクチャー(HCDI)” システム『Insight Qube』...
コモディティサーバー3台で作る高速処理 “ハイパー・コンバージド・データベース・インフラストラクチャー(HCDI)” システム『Insight Qube』...コモディティサーバー3台で作る高速処理 “ハイパー・コンバージド・データベース・インフラストラクチャー(HCDI)” システム『Insight Qube』...
コモディティサーバー3台で作る高速処理 “ハイパー・コンバージド・データベース・インフラストラクチャー(HCDI)” システム『Insight Qube』...
 
複数DBのバックアップ・切り戻し運用手順が異なって大変?!運用性の大幅改善、その先に。。
複数DBのバックアップ・切り戻し運用手順が異なって大変?!運用性の大幅改善、その先に。。 複数DBのバックアップ・切り戻し運用手順が異なって大変?!運用性の大幅改善、その先に。。
複数DBのバックアップ・切り戻し運用手順が異なって大変?!運用性の大幅改善、その先に。。
 
Attunity社のソリューションの日本国内外適用事例及びロードマップ紹介[ATTUNITY & インサイトテクノロジー IoT / Big Data フ...
Attunity社のソリューションの日本国内外適用事例及びロードマップ紹介[ATTUNITY & インサイトテクノロジー IoT / Big Data フ...Attunity社のソリューションの日本国内外適用事例及びロードマップ紹介[ATTUNITY & インサイトテクノロジー IoT / Big Data フ...
Attunity社のソリューションの日本国内外適用事例及びロードマップ紹介[ATTUNITY & インサイトテクノロジー IoT / Big Data フ...
 
レガシーに埋もれたデータをリアルタイムでクラウドへ [ATTUNITY & インサイトテクノロジー IoT / Big Data フォーラム 2018]
レガシーに埋もれたデータをリアルタイムでクラウドへ [ATTUNITY & インサイトテクノロジー IoT / Big Data フォーラム 2018]レガシーに埋もれたデータをリアルタイムでクラウドへ [ATTUNITY & インサイトテクノロジー IoT / Big Data フォーラム 2018]
レガシーに埋もれたデータをリアルタイムでクラウドへ [ATTUNITY & インサイトテクノロジー IoT / Big Data フォーラム 2018]
 

Recently uploaded

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 

Recently uploaded (20)

Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 

[INSIGHT OUT 2011] A21 why why is probably the right answer(tom kyte)

  • 1. <Insert Picture Here> Why “why” (or it depends) is probably the right answer Thomas Kyte http://asktom.oracle.com/
  • 2. Who am I • Been with Oracle since 1993 • User of Oracle since 1987 • The “Tom” behind AskTom in Oracle Magazine www.oracle.com/oramag • Expert Oracle Database Architecture • Effective Oracle by Design • Expert One on One Oracle • Beginning Oracle What we know, shapes how we do things...
  • 3. Why the right first answer is probably “Why, what is your goal” (and the second one is “it depends”) Copyright Kyte Inc. 2005
  • 4. What prompted me to think about this QUOTE its funny how you sometimes have to explain the question in order to get the the answer. It's not "funny", IMHO. It's rude and unproductive for people to assume that you don't know what you are doing. For example, this question is none of XXX’s business, and it assumes that you don't have enough skill to follow standard DBA procedures and best- practices . This person came for answers and suggestions, not to play 20- questions with some anonymous person. If you want to "ask" questions, please feel free to start a thread. . . Copyright Kyte Inc. 2005
  • 5. So, what is wrong with that • Just about everything • Let’s ask some questions Copyright Kyte Inc. 2005
  • 6. How do I reorg a table? • You could answer with any of the following: – Alter table T move, rebuild indexes – Export/Import – Create table as select, index, grant, constrain – DBMS_REDEFINITION – Alter table shrink (10g) – And maybe more. • So, why is “why, what is the goal” the only right answer? Copyright Kyte Inc. 2005
  • 7. How do I reorg a table? • You Alter table T move, rebuild indexes – And say they did that, what did they get? • Took 2 hours of downtime (big table, lots of indexes) • Cost $$$, they could have been doing something truly productive • Did they achieve their goal? Not in this case, their perceived problem was chained rows (say 1,000 of them) • After the reorg, they still had 1,000 chained rows! • We need to ask “WHY”, what is the goal. Copyright Kyte Inc. 2005
  • 8. How do I create a table in a stored procedure • You could answer – Get CREATE TABLE granted directly to you, not via a role. Use EXECUTE IMMEDIATE ‘create table ’ – Or, you could answer “why, what is the goal?” Copyright Kyte Inc. 2005
  • 9. How do I create a table in a stored procedure • Why is Why the right answer? – They were porting from SQL Server. – They had years of database experience. – Just not with Oracle. – Dropping and Creating tables in PL/SQL is not the correct approach in Oracle. – We need to tell them How in Oracle. – They are not stupid, they just don’t know something yet – We are not presumptuous or rude, just responsible Copyright Kyte Inc. 2005
  • 10. How do I reorg a 50gig database At a given customer site, I must reorganize a 50 Gigs Prod DB in a single day. Note that I do not know the environment yet (I am replacing somebody leaving on vacation without providing any analysis report. This guy only re- told this DB is bad, we must re-organize it and left on vacation...). I only know the DB is running on a Windows server, the 50 Gigs DB is mission-critical (hosting the PeopleSoft Financials suite), the DB is said to be highly-fragmented at the tablespace-levels and highly chained at the table-levels but no bad-perf issue has been apparently reported. I do not have disk space to create a new db aside the current one, I only have One Day to successfully carry out the whole thing. What would be the right approach ? Keeping in mind, not to loose anything on the way ... (i.e., low risk). What would be the best strategy ? Copyright Kyte Inc. 2005
  • 11. How do I reorg a 50gig database • I asked “why”, “what is the goal” • Answer: – Tablespace fragmented as reported by Toad – Chained rows, must get rid of chained rows • Turns out peoplesoft uses lots of longs, won’t matter how many times you rebuild will it. • Fragmented tablespace – so what? 1 extent or 500 extents. So what? They don’t drop/truncate, so “so what” • Only answer is “don’t even think about doing this”. What would have happened had I just answered the question! Copyright Kyte Inc. 2005
  • 12. It makes it clear • People asking questions have a lot of inside information • People receiving the question don’t • We need to communicate from person A to person B • And if we ass-u-me the person asking the question has some in depth knowledge – and they don’t, we’ve just really ‘hosed’ them. • It would be irresponsible to not justify their questions Copyright Kyte Inc. 2005
  • 13. Why ask Why? • Because most of the time you won’t have to actually answer after that! – When you find out why, the answer becomes “oh, you don’t need to do that” • Because it is the only responsible thing to do – You don’t know how much the person on the other end of the ethernet cable actually knows • Because it is the only way to get the best answer Copyright Kyte Inc. 2005
  • 14. It depends If Why isn’t the right answer, then this one probably is What is the best way questions Copyright Kyte Inc. 2005
  • 15. ops$tkyte%ORA11GR2> with 2 players as 3 ( select cast( 'P'||rownum as varchar2(2) ) username 4 from all_objects 5 where rownum <= 8), 6 weeks as 7 ( select rownum week 8 from all_objects 9 where rownum <= 7 ), 10 data as 11 ( select username, 12 week, 13 row_number() over (partition by week order by rnd) rn 14 from ( select username, week, dbms_random.random rnd 15 from players, weeks 16 ) 17 ) 18 select * 19 from data 20 pivot( max(username) for rn in (1,2,3,4,5,6,7,8) ) 21 order by week 22 /
  • 16. ops$tkyte%ORA11GR1> with 2 players as 3 ( select cast( 'P'||rownum as varchar2(2) ) username 4 from all_objects 5 where rownum <= 8), 6 … 18 select * 19 from data 20 pivot( max(username) for rn in (1,2,3,4,5,6,7,8) ) 21 order by week 22 / WEEK 1 2 3 4 5 6 7 8 ---------- -- -- -- -- -- -- -- -- 1 P4 P5 P8 P3 P2 P1 P6 P7 2 P5 P8 P7 P2 P6 P1 P4 P3 3 P8 P3 P6 P7 P4 P5 P2 P1 4 P5 P2 P3 P8 P6 P1 P7 P4 5 P6 P8 P1 P7 P5 P2 P4 P3 6 P4 P8 P7 P6 P2 P1 P5 P3 7 P6 P8 P2 P1 P3 P7 P4 P5 7 rows selected.
  • 17. Best Practices defined – Consensus of expert opinions, based <Insert Picture Here> on actual customer experiences in practice. Lessons learned. Proven practices associated with a particular usage profile. Baseline configuration rules - prerequisite to tuning. Sounds all good
  • 18. Best Practices – It is easy with Best Practices to forget that once a <Insert Picture Here> practice has been branded as "Best", that it may represent certain tradeoffs and may involve noteworthy downside potential. It is also easy to forget the context for which any given practice was promoted as "Best", and therefore apply it in some inappropriate context. - Bob Sneed, Sun Microsystems
  • 19. Bryn Llewellyn on Best Practices Prescribing best practice principles for programming any 3GL is phenomenally difficult. One of the hardest challenges is the safety of the assumption that the reader starts out with these qualities • Has chosen common from education.(Howwell- can Knows Oracle toinsidesenseseveral others. else Can natural thefirst technical prose.excellent takes Requiresclassanegotiating mechanical systems. easy accessvisualize self received Database orskills. (Good code first excellenceclassinside out. an PL/SQL right parents. and with write excellent one ability to out. coupled mentors... you write the requirements for your longer to write and test than bad code; managers developed verbal reasoning skills. code, write the test specifications, and discuss problems that arise want code delivered in aggressive timeframes.) along the way?)
  • 20. <Insert Picture Here> “What is the best way..?” – Questions that begin and end with that can drive you nuts. If there was a universal best way to do something, we would not have implemented the other ways AskTom “What is The best way?”
  • 21.
  • 22. <Insert Picture Here> Is there a best way to do something – every time? select * from t1, t2 where t1. id = t2. id and t1.small_distinct = :x • T1 is large, where small_distinct = :x returns much of the table • T2 is large
  • 23. <Insert Picture Here> Is there a best way to do something – every time? select * from t1, t2 where t1. id = t2. Id and t1.small_distinct = :x HASH JOIN SELECT STATEMENT TABLE ACCESS FULL T1 NESTED LOOPS TABLE ACCESS FULL T2 TABLE ACCESS BY INDEX ROWID(T1) INDEX RANGE SCAN T1_IDX TABLE ACCESS BY INDEX ROWID(T2) INDEX UNIQUE SCAN T2_PK
  • 24. <Insert Picture Here> Is there a best way to do something – every time? HASH JOIN SELECT STATEMENT TABLE ACCESS FULL T1 NESTED LOOPS TABLE ACCESS FULL T2 TABLE ACCESS BY INDEX ROWID(T1) INDEX RANGE SCAN T1_IDX TABLE ACCESS BY INDEX ROWID(T2) INDEX UNIQUE SCAN T2_PK call count cpu elapsed disk query Fetch 35227 5.63 9.32 23380 59350 Fetch 35227 912.07 3440.70 1154555 121367981
  • 25. <Insert Picture Here> Is there a best way to do something – every time? HASH JOIN SELECT STATEMENT TABLE ACCESS FULL T1 NESTED LOOPS TABLE ACCESS FULL T2 TABLE ACCESS BY INDEX ROWID(T1) INDEX RANGE SCAN T1_IDX TABLE ACCESS BY INDEX ROWID(T2) INDEX UNIQUE SCAN T2_PK call count cpu elapsed disk query Fetch 1 4.55 5.16 12152 12456 Fetch 1 0.05 0.09 12 15
  • 26. <Insert Picture Here> It takes a context – It is also easy to forget the context for which any given practice was promoted as "Best", and therefore apply it in some inappropriate context Indexes are ‘best’, everyone knows that
  • 27. <Insert Picture Here> It takes understanding too – You need to take the facts, coupled with your knowledge, How do I tune with tkprof
  • 28. <Insert Picture Here> What can you do with this information? select count(subobject_name) from big_table.big_table COUNT(SUBOBJECT_NAME) --------------------- 688256 call count cpu elapsed disk query total 4 99.36 262.11 1840758 1840800 Rows Row Source Operation 1 SORT AGGREGATE (cr=1840797 pr=1840758 pw=0 time=262104893 us) 128000000 TABLE ACCESS FULL BIG_TABLE (cr=1840797 pr=1840758 pw=0 time=384004887 us) Event waited on Times Max. Wait Total Waited db file scattered read 14425 0.22 195.87
  • 29. <Insert Picture Here> First, there are a bunch of facts • Query took a long time – if we make it fast • We did a ton of physical IO – and that is slow • We did a ton of logical IO – and that is not ‘free’ • There is a big difference between elapsed and cpu – we were waiting for something • We can see our query and plan – we know the answer to the query
  • 30. <Insert Picture Here> There are things we have knowledge of • We know the data (it is ours after all) • How Oracle works (hopefully!)
  • 31. <Insert Picture Here> What are some obvious things to think about here? • We needed a very small subset of the rows – 700k out of 128m • The table looks well packed – simple math, divide IO’s (cr=1,840,797) by rows (128,000,000), about 70 rows/block and given we know the average row width (it is our data after all ) that sounds nicely packed • What can we rule out now? Shrink and Rebuild
  • 32. <Insert Picture Here> What are Some possible options? • Make full scan faster • Maybe by compressing the table • Maybe by including subobject_name in some index (to avoid the table) • Remove Full Scan • We are interested in only 0.6% of the data • Maybe a new index would help • Don’t do it or do it differently
  • 33. <Insert Picture Here> In Real Life it Will be more Complex • It will be more complex in general • But the process is the same • Get facts • Infer more facts • Build your context! • Rule things out • Ruling something out is as good as ruling something in • Many best practices will fall by the wayside here
  • 34. Educated Incapacity – A <Insert Picture Here> barrier to creative ideas can be experience, ‘the best way’ "This 'telephone' has too many shortcomings to be seriously considered as a means of communication. The device is inherently of no value to us.“ – Western Union internal memo, 1876. " The concept is interesting and well-formed, but in order to earn better than a 'C,' the idea must be feasible.“ – Yale University management professor in response to Fred Smith's paper proposing reliable overnight delivery service. Smith went on to found Federal Express Corp. Although experience is often valuable, it can be a liability in a search for creative ideas.
  • 35. <Insert Picture Here> So, What is the point?
  • 38. <Insert Picture Here> Learn a new language – else everything will look like a nail. C, C++, PL/I, Rexx, Exec, JCL, SAS, Pascal, Cobol, Java, Ada, PL/SQL, T-SQL, Prolog, Lisp, Scheme, Various Assemblers, many SQL dialects, many scripting languages,
  • 39. <Insert Picture Here> Don’t tune a query – tune a process, an algorithm, the entire approach. Don’t fall into the sunk cost theory
  • 40. <Insert Picture Here> Always Question Everything – in a non-annoying way of course! Question Authority
  • 41. <Insert Picture Here> Collaborate – Participate, Network, Exchange ideas. I learn something new every day about Oracle – from the questions I get about Oracle
  • 42. <Insert Picture Here> The Best Way Thomas Kyte http://asktom.oracle.com/ What we know, shapes how we do things...