rwp training optimizer hands-on exercise - oracle · title: how to use the powerpoint template...

31

Upload: buidat

Post on 31-Mar-2018

217 views

Category:

Documents


3 download

TRANSCRIPT

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training Optimizer Hands-On Exercise

This hands on exercise is a step by step guide which will guide you through resolving issues preventing the optimizer from choosing the optimal execution plans for a set of queries.

Use your assigned user account for the linux login:

– username userXXY e.g. user031

– password userXXY e.g. user031

Overview

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training Optimizer Hands-On Exercise

Then use your team database :

– schema optXXY e.g. opt031

– password optXXY e.g.. opt031

– For example:

– sqlplus opt031/opt031

All of the scripts are in the ~/opt directory.

To get started:

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

1. Run 01.query_1.sql

View the SQL Monitor Report.

Note any problems with the SQL execution.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

2. Run 02.desc_lineorder.sql

Note any issues between the table columns and how the SQL statement is written.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

3. Run 03.query_1.sql

View the SQL Monitor Report.

Why is the SQL statement executing faster now?

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

4. Run 04.query_2.sql

View the SQL Monitor Report.

Note any problems with the SQL execution.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

5. Run 05.check_lineorder_stats.sql

Note any issues with the table stats relative to the two queries.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

6. Run 06.gather_stats_lineorder.sql

Regather stats on the lineorder table.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

7. Run 07.check_lineorder_stats.sql

What changed with the stats on the lineorder table?

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

8. Run 08.query_1.sql

Has the execution plan or time for query 1 changed?

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

9. Run 09.query_2.sql

Has the execution plan or time for query 2 changed?

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

10. Run 10.query_3.sql

View the SQL Monitor Report.

Note any problems with the SQL execution of query 3.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

11. Run 11.query_4.sql

View the SQL Monitor Report.

Note any problems with the SQL execution of query 4.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

12. Run 12.set_parallel.sql

Set the degree of parallel on the tables and indexes.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

13. Run 13.query_3.sql

View the SQL Monitor Report.

Note any changes in the execution plan or run time with parallel execution.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

14. Run 14.query_4.sql

View the SQL Monitor Report.

Note any changes in the execution plan or run time with parallel execution.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

15. Run 15.check_table_stats.sql

Check the table stats.

Are there any issues with the table stats?

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

16. Run 16.check_supplier_column_stats.sql

Check the column stats on the supplier table.

Are there any issues with the column stats?

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

17. Run 17.gather_stats_supplier.sql

Regather stats on the supplier table.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

18. Run 18.check_table_stats.sql

Check the new stats on the supplier table.

Are there any changes?

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

19. Run 19.check_supplier_column_stats.sql

Check the new column stats on the supplier table.

Are there any changes?

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

20. Run 20.query_3.sql

Run query 3 and note any differences in the execution plan and time.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

21. Run 21.query_4.sql

Run query 4 and note any differences in the execution plan and time.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

22. Run 22.column_group_supplier.sql

Create a column group on the supplier table and regather stats.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

23. Run 23.query_4.sql

Run query 4.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

24. Run 24.check_supplier_column_stats.sql

Check the column stats on the supplier table.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

25. Run 25.gather_stats_supplier.sql

Regather stats on the supplier table.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

26. Run 26.check_supplier_column_stats.sql

Check the column stats on the supplier table.

Copyright © 2014, Oracle and/or its affiliates. All rights reserved. |

RWP Training SQL Hands-On Exercise

27. Run 27.query_4.sql

Run query 4.