Oracle filter on plan explanation sections

I am making a proof of concept, and I am experimenting with strange behavior. I have a table broken down by range on a date field, and the cost of the request changes dramatically if I set a fixed date or one created by SYSDATE.

These are the explanatory plans:

SQL> SELECT *
  2    FROM TP_TEST_ELEMENTO_TRAZABLE ET
  3   WHERE ET.FEC_RECEPCION
  4  BETWEEN TRUNC(SYSDATE-2) AND TRUNC(SYSDATE-1)
  5  ;

5109 filas seleccionadas.


Plan de Ejecuci¾n
----------------------------------------------------------
Plan hash value: 1151442660

------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                 | Name                       | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT          |                            |  5008 | 85136 |  4504   (8)| 00:00:55 |       |       |
|*  1 |  FILTER                   |                            |       |       |            |          |       |       |
|   2 |   PARTITION RANGE ITERATOR|                            |  5008 | 85136 |  4504   (8)| 00:00:55 |   KEY |   KEY |
|*  3 |    TABLE ACCESS FULL      | TP_TEST_ELEMENTO_TRAZABLE  |  5008 | 85136 |  4504   (8)| 00:00:55 |   KEY |   KEY |
------------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - filter(TRUNC(SYSDATE@!-2)<=TRUNC(SYSDATE@!-1))
   3 - filter("ET"."FEC_RECEPCION">=TRUNC(SYSDATE@!-2) AND "ET"."FEC_RECEPCION"<=TRUNC(SYSDATE@!-1))


EstadÝsticas
----------------------------------------------------------
          1  recursive calls
          0  db block gets
        376  consistent gets
          0  physical reads
          0  redo size
     137221  bytes sent via SQL*Net to client
       4104  bytes received via SQL*Net from client
        342  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
       5109  rows processed

Using fixed dates:

SQL> SELECT *
  2    FROM TP_TEST_ELEMENTO_TRAZABLE ET
  3   WHERE ET.FEC_RECEPCION
  4  BETWEEN  TO_DATE('26/02/2017', 'DD/MM/YYYY') AND  TO_DATE('27/02/2017', 'DD/MM/YYYY')
  5  ;

5109 filas seleccionadas.


Plan de Ejecuci¾n
----------------------------------------------------------
Plan hash value: 3903280660

-----------------------------------------------------------------------------------------------------------------------
| Id  | Operation                | Name                       | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
-----------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT         |                            |  5008 | 85136 |    11   (0)| 00:00:01 |       |       |
|   1 |  PARTITION RANGE ITERATOR|                            |  5008 | 85136 |    11   (0)| 00:00:01 |   607 |   608 |
|*  2 |   TABLE ACCESS FULL      | TP_TEST_ELEMENTO_TRAZABLE  |  5008 | 85136 |    11   (0)| 00:00:01 |   607 |   608 |
-----------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - filter("ET"."FEC_RECEPCION"<=TO_DATE(' 2017-02-27 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))


EstadÝsticas
----------------------------------------------------------
          1  recursive calls
          0  db block gets
        376  consistent gets
          0  physical reads
          0  redo size
     137221  bytes sent via SQL*Net to client
       4104  bytes received via SQL*Net from client
        342  SQL*Net roundtrips to/from client
          0  sorts (memory)
          0  sorts (disk)
       5109  rows processed

What is the difference that gives a value of 4504 and a value of 11?

Thanks in advance:)

+4
source share
1 answer

, , SYSDATE, . , , , , . , KEY: KEY, , .

, . , "" .

+5

Source: https://habr.com/ru/post/1671067/


All Articles