10.07.2015 Views

Expert Oracle Exadata - Parent Directory

Expert Oracle Exadata - Parent Directory

Expert Oracle Exadata - Parent Directory

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 16 UNLEARNING SOME THINGS WE THOUGHT WE KNEWdeductive reasoning will go a long way toward figuring out what has gone wrong should the complaints come in.Having said all that, let’s not forget for a moment that DW/BI workloads must burn CPU. That is the nature of thebeast as it were. Life is a never-ending series of choices.CASE StatementsCASE statements (and their older cousin the DECODE function) are often used to avoid repeated scans ofthe same table. Generally speaking this is a reasonable technique, although analytic functions nowprovide another way to deal with this issue. Nevertheless, it is quite common to see code that appliesthis trick. The whole idea is to replace WHERE clauses with CASE statements. This is perfectly reasonablewhen all the blocks must be shipped back to the database server to be evaluated. But with <strong>Exadata</strong>’sability to do filtering at the storage layer, this technique may not be the best solution. Here’s a quickexample:SYS@SANDBOX1> alter session set cell_offload_processing=false;Session altered.Elapsed: 00:00:00.00SYS@SANDBOX1>-- Without Smart ScansSYS@SANDBOX1> select /*+ full(a) */ count(*) from kso.skew a where col1 =1;COUNT(*)----------3199971Elapsed: 00:00:11.04SYS@SANDBOX1> select /*+ full(a) */ count(*) from kso.skew a where col1 = 999999;COUNT(*)----------32Elapsed: 00:00:10.52SYS@SANDBOX1> select sum(case when col1 = 1 then 1 else 0 end) how_many_ones,2 sum(case when col1 = 999999 then 1 else 0 end) how_many_nines3 from kso.skew;HOW_MANY_ONES HOW_MANY_NINES---------------------------3199971 32Elapsed: 00:00:12.83So you can see that without offloading, combining the statements basically cuts the elapsed time inhalf. This is what we’re used to seeing on a non-<strong>Exadata</strong> platform. Now let’s see what happens when weenable Smart Scans:524

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!