# Aggregate Reflection not used

**URL:** <https://community.dremio.com/t/aggregate-reflection-not-used/375>\
**Category:** Uncategorized\
**Created:** [October 16, 2017, 10:31am UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375 "2017-10-16T10:31:50Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![druthven](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@druthven](https://community.dremio.com/u/druthven)\
**Post date:** [October 16, 2017, 10:31am UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/1 "2017-10-16T10:31:50Z")

</div>

I have an Oracle database table with 20 million rows. The following simple aggregation takes 9 seconds to run:

select object\_type, count(_) nobjs from big\_table group by object\_type order by count(_) desc

I created a reflection but it is not used:

Query and Planning

Query  
Visualized Plan  
Planning  
Acceleration  
Reflection Outcome

Query was NOT accelerated

b7ac073f-2559-4aea-aa1b-ac3a378bc536 (agg): considered, not matched.  
Time To Find Reflections: 0 ms  
Time To Canonicalize: 2 ms  
Time To Match: 0 ms

I can upload a profile if required.

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [October 16, 2017, 3:43pm UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/2 "2017-10-16T15:43:05Z")

</div>

HI @druthven,

Happy to help. What version of Dremio are you using? Can you please upload the profile?

Thanks,  
@balaji.ramaswamy

---

<div class="post-metadata">

**Author:** ![druthven](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@druthven](https://community.dremio.com/u/druthven)\
**Post date:** [October 16, 2017, 7:57pm UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/3 "2017-10-16T19:57:03Z")

</div>

Latest community edition downloaded yesterday.

Have uploaded the profile.

-David

[b8046d8a-9d92-4d2e-bc25-803810281a96.zip](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/1X/abfb22fa0447d78a4ab7dd89954fa990cf2f9f8f.zip) (3.6 KB)

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [October 16, 2017, 9:22pm UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/4 "2017-10-16T21:22:35Z")

</div>

Hi @druthven

Can you please send me the profile for the reflection you created?

Thanks  
@balaji.ramaswamy

---

<div class="post-metadata">

**Author:** ![druthven](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@druthven](https://community.dremio.com/u/druthven)\
**Post date:** [October 17, 2017, 6:03am UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/5 "2017-10-17T06:03:21Z")

</div>

How do I send a profile for the reflection itself?

---

<div class="post-metadata">

**Author:** ![druthven](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@druthven](https://community.dremio.com/u/druthven)\
**Post date:** [October 18, 2017, 9:47am UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/6 "2017-10-18T09:47:11Z")

</div>

Attached is the profile for the aggregate reflection.[da9cd178-bbdf-45ec-b74d-c2f0d9f27574.zip](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/1X/9e19bc176264cbd74d2829b69f7d8c7e3976485b.zip) (4.2 KB)

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [October 18, 2017, 3:36pm UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/7 "2017-10-18T15:36:19Z")

</div>

Thanks @druthven, let me try this on my local Oracle Database and get back to you. I will create the reflection on the below SQL and get back to you on the acceleration result

```
SELECT OBJECT_TYPE object_type,
        COUNT(1) nobjs
FROM DELPHIXDB.BIG_TABLE
GROUP BY OBJECT_TYPE

```

Thanks,  
@balaji.ramaswamy

---

<div class="post-metadata">

**Author:** ![druthven](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@druthven](https://community.dremio.com/u/druthven)\
**Post date:** [October 18, 2017, 3:51pm UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/8 "2017-10-18T15:51:04Z")

</div>

Here is how I created the table:

drop table big\_table;

create table big\_table  
as  
select rownum id,  
OWNER, OBJECT\_NAME, SUBOBJECT\_NAME,  
OBJECT\_ID, DATA\_OBJECT\_ID,  
OBJECT\_TYPE, CREATED, LAST\_DDL\_TIME,  
TIMESTAMP, STATUS, TEMPORARY,  
GENERATED, SECONDARY  
from all\_objects a  
where 1=0  
/  
alter table big\_table nologging;

declare  
l\_cnt number;  
l\_rows number := &1;  
begin  
insert /\*+ append \*/  
into big\_table  
select rownum,  
OWNER, OBJECT\_NAME, SUBOBJECT\_NAME,  
OBJECT\_ID, DATA\_OBJECT\_ID,  
OBJECT\_TYPE, CREATED, LAST\_DDL\_TIME,  
TIMESTAMP, STATUS, TEMPORARY,  
GENERATED, SECONDARY  
from all\_objects a  
where rownum \<= &1;

```
l_cnt := sql%rowcount;

commit;

while (l_cnt < l_rows)
loop
    insert /*+ APPEND */ into big_table
    select rownum+l_cnt,
           OWNER, OBJECT_NAME, SUBOBJECT_NAME,
           OBJECT_ID, DATA_OBJECT_ID,
           OBJECT_TYPE, CREATED, LAST_DDL_TIME,
           TIMESTAMP, STATUS, TEMPORARY,
           GENERATED, SECONDARY
      from big_table
     where rownum <= l_rows-l_cnt;
    l_cnt := l_cnt + sql%rowcount;
    commit;
end loop;

```

end;  
/

alter table big\_table add constraint  
big\_table\_pk primary key(id)  
/

begin  
dbms\_stats.gather\_table\_stats  
( ownname =\> user,  
tabname =\> ‘BIG\_TABLE’,  
cascade =\> TRUE );  
end;  
/  
select count(\*) from big\_table;

select object\_type, count(_) from big\_table group by object\_type order by count(_) desc;

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [October 19, 2017, 10:02pm UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/9 "2017-10-19T22:02:42Z")

</div>

Hi @druthven,

I was able to create the exact same table on Oracle 11GR2 but the acceleration seems to work fine for me. The only difference is I am on the Enterprise Edition. I am also going to try the same on the Community Edition. Please see attached file that has the SQL statements I ran inside of Oracle. I have also attached 2 screenshots

1. Create-Agg-Reflection - Show the Agg Reflection columns I used
2. Query-Accelarated-View - Screen shot from the job profile that says Query was accelarated

The query I ran on Dremio is below,

`select object_type, count(object_name) from "Oracle-XE ".OPERATIONAL.big_table group by object_type order by count(object_name) desc`

Will try the same on Community Edition and let you know the results

Thanks  
@balaji.ramaswamy

 ![Query-Accelarated-View](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/1X/42bd9142bf3c6c7a09f0b947f90d30af053db700.png) ![Create-Agg-Reflection](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/1X/cb80fc0090c88c2f7c351881719dfc4f428bb29e.png)

---

<div class="post-metadata">

**Author:** ![druthven](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@druthven](https://community.dremio.com/u/druthven)\
**Post date:** [October 20, 2017, 7:00am UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/10 "2017-10-20T07:00:31Z")

</div>

Your query is slightly different to mine, mine uses ‘count(\*)’ where yours uses ‘count(object\_name)’. Anyway I tried your query. My aggregation screen does not offer the same options:

 ![27](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/1X/df2466b4665f81d45a04c9001c308d4ab627bfa2.png)

So I cannot add the measure ‘object\_name’ the only choice is ‘EXPR$1’

---

<div class="post-metadata">

**Author:** ![druthven](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@druthven](https://community.dremio.com/u/druthven)\
**Post date:** [October 27, 2017, 6:53am UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/11 "2017-10-27T06:53:50Z")

</div>

Does this work with the enterprise edition? If so, is that the only method to test dremio with Oracle sources?

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [October 27, 2017, 3:42pm UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/12 "2017-10-27T15:42:38Z")

</div>

Hi @druthven,

Let me get back to you on this. I will have the steps done on the community edition

Thanks,  
@balaji.ramaswamy

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [October 27, 2017, 4:07pm UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/13 "2017-10-27T16:07:14Z")

</div>

Hi @druthven

I was able to quickly test this on community edition and acceleration works as expected. Please see screenshots attached. For my example, BIG\_TABLE has “100,000” rows

When you click on “Aggregate Reflections”, does it show all columns of “BIG\_TABLE”?

Thanks,  
@balaji.ramaswamy ![Query](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/1X/b32ea8539203002f2220d8aca07b08aaffef1a75.png) ![Accelaration](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/1X/c81c4b4f3d66af7e694b94fb19707901b09cb9aa.png)

 ![Aggregate](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/1X/964afbd6bd06d2731cd59f5e46e279af836207ba.png)

---

<div class="post-metadata">

**Author:** ![druthven](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@druthven](https://community.dremio.com/u/druthven)\
**Post date:** [October 27, 2017, 5:26pm UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/14 "2017-10-27T17:26:02Z")

</div>

> When you click on “Aggregate Reflections”, does it show all columns of “BIG\_TABLE”?  
> No, is there a new version of the community edition? I am running 1.2.2-201710100154510864-d40e3

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [October 27, 2017, 6:00pm UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/15 "2017-10-27T18:00:27Z")

</div>

Hi @druthven,

That should not change, Have you created the VDS on the entire dataset “select \* from big\_table” or on the aggregate query?

Thanks,  
@balaji.ramaswamy

---

<div class="post-metadata">

**Author:** ![druthven](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@druthven](https://community.dremio.com/u/druthven)\
**Post date:** [October 27, 2017, 10:34pm UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/16 "2017-10-27T22:34:39Z")

</div>

I only used the aggregate query. Can you send me an explicit list of the steps you took?

---

<div class="post-metadata">

**Author:** ![balaji.ramaswamy](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/balaji.ramaswamy/32/843_2.png) [@balaji.ramaswamy](https://community.dremio.com/u/balaji.ramaswamy)\
**Post date:** [October 27, 2017, 11:26pm UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/17 "2017-10-27T23:26:15Z")

</div>

Oracle backend steps remain same

Step 1: On the Dremio UI, click on the Oracle Data Source-Schema-Table. This would run a select \* on the table like below

`SELECT * FROM "DELPHIXDB".BIG_TABLE`

Step 2: Save the result set as a Virtual Data Set (VDS) by clicking “Save As” and give a name like “big\_table”

Step 3: Click on the settings of the VDS and click on reflections

Step 4: Enable Aggregate reflections

Step 5: From the table columns listed on the left drag object\_type to the “Dimensions” section

Step 6: From the table columns listed on the left drag object\_id to the “Measures” section and Save the reflection

Step 7: Click on a new query and run the aggregate query of the VDS “big\_table”

Step 8: Open the profile of the jib and see if query is accelerated

If you gt stuck, let me know and I can send you a screen recording

Thanks,  
@balaji.ramaswamy

---

<div class="post-metadata">

**Author:** ![druthven](https://avatars.discourse-cdn.com/v4/letter/d/a9a28c/32.png) [@druthven](https://community.dremio.com/u/druthven)\
**Post date:** [October 28, 2017, 10:36am UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/18 "2017-10-28T10:36:14Z")

</div>

That worked, thank you. It generated the following SQL when creating the aggregation accelerator:

SELECT “OBJECT\_TYPE”, SUM(“OBJECT\_ID”) “agg-4-0”, COUNT(“OBJECT\_ID”) “agg-4-1”, MAX(“OBJECT\_ID”) “agg-4-2”, MIN(“OBJECT\_ID”) “agg-4-3”, COUNT(1) "CONVERT\_COUNT\_STAR"  
FROM “DELPHIXDB”."BIG\_TABLE"  
GROUP BY “OBJECT\_TYPE”

I assume that query was used to create the materialized view? How can I check the contents of the materialized view? The following query

SELECT \* FROM “\_\_materialization”.“e9dc52cb-6dbd-458e-8741-7adfef5c2837”

gets: “Table ‘\_\_materialization.e9dc52cb-6dbd-458e-8741-7adfef5c2837’ not found”

---

<div class="post-metadata">

**Author:** ![kelly](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/kelly/32/11_2.png) [@kelly](https://community.dremio.com/u/kelly)\
**Post date:** [October 29, 2017, 6:53am UTC](https://community.dremio.com/t/aggregate-reflection-not-used/375/19 "2017-10-29T06:53:20Z")

</div>

There may be a way to do this, I’m unsure and will defer to one of my colleagues.

We haven’t really designed Dremio for reflections to be user accessible. Can you say more about what you’re trying to accomplish? Or are you simply trying to verify the contents of the reflection?

If you look at your job history you can see whether the query was accelerated by the presence of the flame:

![image](https://us1.discourse-cdn.com/flex020/uploads/dremio/original/1X/aa59452d766f5825b871199ac8d85172a8fc36e6.png)

As you noted in your original post in this thread, you can see whether it was accelerated by looking at the query profile. If the query was accelerated then the reflection was used to generate the results. I suppose you can verify the contents of the reflection by checking the results of accelerated queries.
